From jerome@hivnet.ubc.ca  Mon Nov  5 22:41:16 2001
From: jerome@hivnet.ubc.ca (jerome@hivnet.ubc.ca)
Date: Mon, 5 Nov 2001 23:41:16 +0100 (MET)
Subject: [Rd] stepwise algorithm step() on coxph() (PR#1159)
Message-ID: <200111052241.XAA06884@pubhealth.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] stepwise algorithm step() on coxph() (PR#1159)
jerome@hivnet.ubc.ca