[R] Problem in anova with coxph object

Matthias Gondan matthias-gondan at gmx.de
Wed Jan 9 08:45:58 CET 2008


Peter Dalgaard schrieb:
> Matthias Gondan wrote:
>   
>> Dear R users,
>>
>> I noticed a problem in the anova command when applied on
>> a single coxph object if there are missing observations in
>> the data:
>>     
...
>> In the documentation for anova.coxph, there is a warning that
>>  
>>     
>>> The comparison between two or more models by |anova| or will only be 
>>> valid if they are fitted to the same dataset. This may be a problem if 
>>> there are missing values.
>>>
>>>     
>>>       
>> However, I inserted a single object to be analyzed sequentially. Is
>> this a bug in R, or is it covered by the warning?
>>   
>>     
> Notice that you also lose the 18 observations in the comparison of  .~rx
> with the empty model.
>
> This is standard, losing observations on the way through an anova table
> leads to madness.
>
> What happens if you do something like
>
> coxph(Surv(time, status) ~ rx, 
> data=colondeath, subset=complete.cases(nodes))
>   

Then it is working fine, see here:

 > m = coxph(Surv(time, status) ~ rx + sex + age + perfor + nodes, 
data=colondeath, subset=complete.cases(nodes))
 > m
Call:
coxph(formula = Surv(time, status) ~ rx + sex + age + perfor +
    nodes, data = colondeath, subset = complete.cases(nodes))


              coef exp(coef) se(coef)      z       p
rxLev     -0.08245     0.921  0.11168 -0.738 0.46000
rxLev+5FU -0.40310     0.668  0.12054 -3.344 0.00083
sex       -0.02854     0.972  0.09573 -0.298 0.77000
age        0.00547     1.005  0.00405  1.350 0.18000
perfor     0.19040     1.210  0.26335  0.723 0.47000
nodes      0.09296     1.097  0.00889 10.460 0.00000

Likelihood ratio test=88.3  on 6 df, p=1.11e-16  n= 911
 > anova(m, test='Chisq')
Analysis of Deviance Table
 Cox model: response is Surv(time, status)
Terms added sequentially (first to last)

        Df  Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL                       911     5700.6         
rx       2      12.6       909     5688.0 1.866e-03
sex      1 2.523e-03       908     5688.0       1.0
age      1       0.4       907     5687.6       0.5
perfor   1       0.4       906     5687.2       0.5
nodes    1      74.9       905     5612.3 4.898e-18

Thanks!




More information about the R-help mailing list