On Jan 28, 2014, at 10:32 AM, Oscar Rueda wrote: > 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.
Wrong ... in what way? > Would anybody please explain to me why? Perhaps because anova is a generic function and you were expecting anova.cph to be used but the coxph function is not from pkg:rms but rather from pkg:survival. methods(anova) # with both rms and survival loaded > methods(anova) [1] anova.coxmelist* anova.coxph* anova.coxphlist* anova.glm [5] anova.glmlist anova.glmmPQL* anova.lm anova.loess* [9] anova.loglm* anova.mlm anova.negbin* anova.nls* [13] anova.polr* anova.rms* anova.rq anova.rqlist [17] anova.survreg* anova.survreglist* > > 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 > ______________________________________________ > R-help@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. David Winsemius Alameda, CA, USA ______________________________________________ R-help@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.