I've been reading about generalised additive models. I've been using this data (which is a reformatted version of data from Hastie's website), and running my code in R. This data essentially consists of whether a patient has or does not have coronary heart disease (the variable to be modelled) and several patient characteristics. For the sake of this question, the two I am interested in are sbp (sytolic blood pressure) and chol.ratio (the ratio of two types of cholesterol). I've been trying to model chd with logistic regression.

Looking at scatterplots sbp seems non-linearly related to the logit, so I've modelled it with splines as follows:

Using gam:

data1 <- read.csv("coris.csv", sep = ",", stringsAsFactors = F,
                            header = T)
gam.object <- gam(chd ~ s(sbp, 5) + chol.ratio, data = data1,
                          family = binomial(link = "logit"))

And using the Design package:

rcs.object <- lrm(chd ~ rcs(sbp, 6) + chol.ratio, data = data1)

I can plot the subsequent models in 3d using the rcl() package, and the outputs are very similar - the model using GAM is:

enter image description here

The plane represents the fitted model over a range of the predictor variables, and the points are the actual fitted model, the z axis to the right is the cholesterol ratio, and the x axis to the left is the sytolic blood pressure, and the vertical axis is the logit.

and the model using lrm with a rcs is :

enter image description here

So - with the lrm command are you actually fitting a generalized additive model if you specify a spline with rcs()? If not, why not, and how do the two approaches differ?


1 Answer 1


With the lrm command using rcs() you are constructing a cubic spline which is then used in the logistic regression. However, no penalty is applied to the coefficients of the cubic spline, unlike in gam, where a penalty for "roughness" is applied and the appropriate magnitude of the penalty is estimated using generalized cross-validation. lrm and ols from the Design package do have options for penalized estimation, though.

Also note that gam has options for other types of smooth functions than just cubic splines.

Whether or not lrm with rcs is a "generalized additive model" depends, I suppose, on whether one thinks that not having a roughness penalty when fitting a spline takes you out of the spline-based gam framework or not.

  • $\begingroup$ Thanks. In the 3d versions of the above, the gam model looks smoother than the lrm one with rcs, but it's not obvious in the images (I did try to take them from a good angle). Does the roughness penalty account for the increased smoothness in the gam model? $\endgroup$
    – Andrew
    Dec 15, 2011 at 10:03
  • 1
    $\begingroup$ Yes, it does. The roughness penalty forces the coefficients of the cubic spline towards zero (i.e., towards a linear fit) relative to what they would be with no penalty; this acts to smooth out the spline's curve. $\endgroup$
    – jbowman
    Dec 15, 2011 at 15:03
  • 2
    $\begingroup$ Allow me to modify that statement. The roughness penalty would act as I said, and, if the splines have the same number and location of knots, then the roughness penalty makes the spline smoother. However, it is likely that the splines that made up your plot were differently parameterized to start with. The penalty would make the penalized spline smoother than it would otherwise be, but, depending upon the parameterization, it might still be rougher than the other spline. $\endgroup$
    – jbowman
    Dec 15, 2011 at 15:57
  • $\begingroup$ Thanks! It's good to know that things are always more complicated than I think. $\endgroup$
    – Andrew
    Dec 15, 2011 at 16:29

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.