[R] anova.coxph with subsets of data

Oscar Rueda Oscar.Rueda at cruk.cam.ac.uk
Tue Jan 28 19:32:37 CET 2014


Dear list, 
I'm using the rms package to fit some Cox models. I run anova() on them to obtain sequential p-values, but I'm getting strange results when I run it on a subset of the data. 

Following the example on the help page of anova.coxph:
> library(rms)
> data(ovarian)
> fit <- coxph(Surv(futime, fustat) ~ resid.ds *rx + ecog.ps, data = ovarian)
> anova(fit)
> fit2 <- coxph(Surv(futime, fustat) ~ resid.ds +rx + ecog.ps, data=ovarian)
> anova(fit2,fit)

would give me the same result, as expected. 
But If I do

> fit <- coxph(Surv(futime, fustat) ~ resid.ds *rx + ecog.ps, data = ovarian, subset=ovarian$age>50)
>  anova(fit)
>  fit2 <- coxph(Surv(futime, fustat) ~ resid.ds +rx + ecog.ps, data=ovarian, subset=ovarian$age>50)
>  anova(fit2,fit)

The first p-value seems to be wrong. 
Would anybody please explain to me why?

Cheers, 
Oscar

PS. I'm using R 3.0.1.

Oscar M. Rueda, PhD.
 Postdoctoral Research Fellow, Caldas Lab, Breast Cancer Functional
 Genomics.
 University of Cambridge. Cancer Research UK Cambridge Institute.
 Li Ka Shing Centre, Robinson Way.
 Cambridge CB2 0RE
 England


More information about the R-help mailing list