Re: [R] Anova for stratified Cox regression

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Tue, 15 Jan 2008 17:41:24 +0100

Matthias Gondan wrote:
> Dear List,
>
> I have tried a stratified Cox Regression, it is working fine, except for
> the "Anova"-Tests:
>
> Here the commands (should work out of the box):
>
> library(survival)
> d = colon[colon$etype==2, ]
> m = coxph(Surv(time, status) ~ strata(sex) + rx, data=d)
> summary(m)
> # Printout ok
> anova(m, test='Chisq')
>
> This is the output of the anova command:
>
>
>> 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 929 5233.5
>> strata(sex) 0 929
>> rx 2 927 5221.2
>> Warning message:
>> In is.na(coef(fit)) :
>> is.na() auf nicht-(Liste oder Vektor) des Typs 'NULL' angewendet
>>
>
> It should be possible to do Chi-Square-Tests in a stratified analysis,
> right?
>
Yes. anova.coxph() should keep the strata term out of things.

drop1() has the same issue, but it does at least give the right test:

 > drop1(m, test='Chisq')
Single term deletions

Model:
Surv(time, status) ~ strata(sex) + rx

            Df    AIC    LRT  Pr(Chi)
<none>         5225.2
strata(sex)  0 5852.2  627.0
rx           2 5233.5   12.2 0.002215 **

or, it the irrelevant line bothers you,

drop1(m, scope=~.-strata(sex), test='Chisq')

I would have thought that at least this would work, but no:
> anova(update(m, ~.-rx), m, test='Chisq')
Analysis of Deviance Table

Model 1: Surv(time, status) ~ strata(sex) Model 2: Surv(time, status) ~ strata(sex) + rx   Resid. Df Resid. Dev Df Deviance P(>|Chi|)

1       929
2       927     5221.2   2

Warning message:
In is.na(coef(x)) : is.na() applied to non-(list or vector) of type 'NULL'

(Did you check the latest version? Mine is what came with 2.6.1.)

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 15 Jan 2008 - 16:45:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Jan 2008 - 17:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive