Ales - I have identified the problem. It is caused by missing data. In my previous posting I was analysing a dataset which happened to have 190 missing values in the covariate. I compared two models:

r0 <- survreg(s ~1)
r1 <- survreg(s~x)
anova(r0,r1)

I was using anova to investigate the significance of adding covariates to the model, rather than printing out the results of a survreg() directly, and this was the problem. The behaviour of anova() is subtly different when applied to lm() or survreg(). With lm(), if the models compared have different numbers of missing observations, you get a warning, but with survreg(), the difference in observation count shows up as a large change in the df and deviance, giving the appearence that the covariate has been fitted as a factor with 191 levels.

So my fault, although possibly anova(survreg()) should be consistent with anova(lm()).


-Richard


Ales Ziberna wrote:

As you can se from the example bellow, survreg works prefeclty fine with numerical values. (I'm runing R2.0.1 on WinXP(SP2) and 32bit AMD with survival version 2.17.).

As the posting guide asks, plese provide a small example.

Ales Ziberna


library(survival)

Loading required package: splines

data(cancer)
survreg(Surv(time, status)~age,data=cancer)

Call: survreg(formula = Surv(time, status) ~ age, data = cancer)

Coefficients:
(Intercept)         age
6.88712062 -0.01360829

Scale= 0.7587515

Loglik(model)= -1151.9   Loglik(intercept only)= -1153.9
       Chisq= 3.91 on 1 degrees of freedom, p= 0.048
n= 228

----- Original Message ----- From: "Richard Mott" <[EMAIL PROTECTED]>
To: <r-help@stat.math.ethz.ch>
Sent: Tuesday, April 26, 2005 11:32 PM
Subject: [R] survreg with numerical covariates



Does anyone know if the survreg function in the survival package can fit numerical covariates ?

When I fit a survival model of the form

survreg( Surv(time,censored) ~ x )

then x is always treated as a factor even if it is numeric (and even if I try to force it to be numeric using as.numeric(x). Thus, in the particular example I am analysing, a simple numerical covariate becomes a factor with 190 levels. Is this the expected behaviour ? Am I doing something wrong ?

I am running R 2.0.1 on a 64bit Debian Linux system, and version 2.17 of the survival package


Thanks

Richard Mott

--
----------------------------------------------------
Richard Mott       | Wellcome Trust Centre
tel 01865 287588   | for Human Genetics
fax 01865 287697   | Roosevelt Drive, Oxford OX3 7BN

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html






--
----------------------------------------------------
Richard Mott | Wellcome Trust Centre tel 01865 287588 | for Human Genetics
fax 01865 287697 | Roosevelt Drive, Oxford OX3 7BN


______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to