[Rd] stepwise algorithm step() on coxph() (PR#1159)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Tue, 6 Nov 2001 09:17:34 +0100 (MET)


This is not an error.  Nobody said step would work with coxph models.
The help page says

  object: an object representing a model of an appropriate class. This
          is used as the initial model in the stepwise search.

and you are jumping to conclusions.  I've added a note to the help file.

There is an extractAIC.coxph method for use with stepAIC in package MASS.
That does work in your example.

I had a report about multinom fits and step() recently: same answer, it is
stepAIC that works, not step.

Think of step() as minimal implementation to provide some compatibility
with that in S (which only offers lm and glm methods).  And as step() in S
works with deviances, the compatibility function does too.


On Mon, 5 Nov 2001 jerome@hivnet.ubc.ca wrote:

> Full_Name: Jerome Asselin
> Version: 1.3.1
> OS: MacOS 9.2
> Submission from: (NULL) (142.103.173.46)
>
>
>
> The step() function attempts to calculate the deviance of fitted models even if
> does not really need it. As a consequence, the step() function gives an error
> when it is used with coxph(). (There is currently no method to calculate the
> deviance of coxph() fits.) The code below gives an example of how the deviance
> is not necessary (at least for the default parameters of step()). Note that the
> deviance does not seem necessary even for linear models (lm()).
>
> #########################
> library(survival)
>
> set.seed(3)
>
> #Create a fake dataset
> y <- rgamma(10,1)
> x1 <- rnorm(10)
> x2 <- rnorm(10)
> x3 <- rnorm(10)
>
> step(coxph(Surv(y) ~ x1+x2+x3)) #Gives an error
> step(lm(y ~ x1+x2+x3))
> step(glm(y ~ x1+x2+x3))
> step(aov(y ~ x1+x2+x3))
>
> #Mask the deviance() function (Temporary patch??)
> deviance <- function(...) NA
>
> step(coxph(Surv(y) ~ x1+x2+x3)) #Gives no error
> step(lm(y ~ x1+x2+x3)) #Same result as before
> step(glm(y ~ x1+x2+x3))#Same result as before
> step(aov(y ~ x1+x2+x3))#Same result as before
>
> rm(deviance)
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._