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

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 2 11:30:08 CEST 2005


R itself does not have a function rcs(), and help.search("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 help.search() 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
rcspline.restate(Hmisc)
                         Re-state Restricted Cubic Spline Function
GtkVisibility(RGtk)     Automatically generated S functions for
                         bindings to the RGtk library
mysqlInitDriver(RMySQL)
                         Support Functions
sqliteInitDriver(RSQLite)
                         Support Functions
prob.frcs.dat(verification)
                         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,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list