Re: [R] Restricted cubic spline function ERROR?: glm(Y~rcs(x,5))

From: Prof Brian Ripley <>
Date: Mon 02 May 2005 - 19:30:08 EST

R itself does not have a function rcs(), and"rcs") does not find one. My guess is that you are using package Design and failing to tell us.

[Aside here: this is not the first time I have seen results that give no indication why the result was found. To wit

Design.trans(Design)    Design Special Transformation Functions
rcspline.eval(Hmisc)    Restricted Cubic Spline Design Matrix
rcspline.plot(Hmisc)    Plot Restricted Cubic Spline Function
                         Re-state Restricted Cubic Spline Function
GtkVisibility(RGtk)     Automatically generated S functions for
                         bindings to the RGtk library
                         Support Functions
                         Support Functions
                         Probablisitic Forecast Dataset.

is not much help and suggested to me to look at the second to fourth entries.]

If you read the help page ?Design.trans you will see that rcs is part of the Design system built on top of S/R. What makes you think it is intended to work with glm()?

On Mon, 2 May 2005, Jan Verbesselt wrote:

> Is the restricted cubic spline function working properly in the glm model?
> We used glm(y~rcs(x,5), family=binomial) but it seems that for some
> theoretical reasons the rcs, restricted cubic spline function can not be
> fitted by a glm function. Is this correct?
> ((Originally, we used lrm(y~ rcs(x,5)) but we couldn't find how to derive
> the AIC value of the fitted model. Is there a solution?))

Yes. Make use of your theory to write an AIC() method.

Note that

lrm> fit <- lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol,

     4)), x = TRUE, y = TRUE)
> class(fit)

[1] "lrm" "Design" "glm"

is apparently incorrectly asserting inheritance and so the current logLik and hence AIC methods selected do not work. (An "lrm" object is missing the "family" component that is documented for a "glm" object, and in any case I believe lrm also fits non-GLM models.)

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Mon May 02 19:36:46 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:31 EST