I have a series of patients in whom I have measured the value of a certain blood quantity at several time points. However, the time points vary a lot and the number of measurements range between 2 and 5. I would like to fit a smoothing spline to a graph were I have each patient's blood values on the Y-axis and time on the X-axis. I would like to have a graph like the one shown below

enter image description here

I am using R, and with the smooth.spline function I can have a smoothing spline with all data-points used, but I think I should consider each patient's data points as dependent and hence I cannot put them just to a two vector.

How could I produce a smoothing as shown above?

  • $\begingroup$ Apparently I should be using generalized additive models. I was wondering how I can feed have several linear models to gam() function. Each patient has own characteristic linear model (as shown in picture) and I cannot consider all patient together thus ignoring within-patient variations. $\endgroup$
    – arkiaamu
    Jun 6, 2014 at 9:24

1 Answer 1


As you suggest, it may be that generalized additive models are suitable, but you may need something more general.

If the individual variation is just noise around a common underlying population model, a GAM sounds quite sensible.

However, if, as you seem to be suggesting) individuals have some variation in underlying curves (i.e. not simply noise about a common curve), you would usually use mixed models, so if you think you need GAMs, but with capacity for individual variation in curves, you may want generalized additive mixed models (GAMMs). e.g. see the R package gamm4 and the random and re functions in gamlss.

(Another possibility would be some kind of semiparametric model with a mixed parametric term - e.g. you might use something like that for parallel curves, for example. You might need something like a semiparametric model because of the issue where they all are measured at different times)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.