Question

I´m having problem with the anova function in the rms package:

require(rms)
getHdata(prostate)

mod1<-cph(Surv(dtime,status!="Alive")~stage+rx+age+wt,data=prostate,x=T,y=T)
mod2<-cph(Surv(dtime,status!="Alive")~stage+rx+rcs(age,4)+wt,data=prostate,x=T,y=T)
anova(mod1)
anova(mod2)

-everything works alright, but when I try to compare the models for the impact of non-linearity on age

anova(mod1,mod2)

I get

Error in anova.rms(mod1, mod2) : factor names not in design:  mod2

What does this mean? What can I do to circumvent it?

//M

Was it helpful?

Solution

You should be able to use the output of anova(mod2) as one way to assess the significance but the best answer would be to compare the -2*log(likelihood) statistics. The anova.rms function is not designed to take two model fits. The second and subsequent unnamed arguments are assumed to be names of terms within the model rather than fit objects.

(Note that with rcs terms you will not see the sum of individual terms equal the full model chi-square values. I have asked Harrell about this and he says to do the cross-model comparisons "by hand".)

OTHER TIPS

This comparison is done using lrtest (per Misha's comment).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top