Dr Vicki
Dr Vicki

Reputation: 125

Likelihood Ratio Test for Cox Models in R

Does anyone know of a likelihood ratio test, like lrtest in the lmtest package, that works for cox proportional hazards models produced using coxph? lrtest does not seem to work for coxph models.

Thanks

Upvotes: 5

Views: 16099

Answers (2)

IRTFM
IRTFM

Reputation: 263362

There is an anova.coxph in pkg:survival which allows comparison of model objects.

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

Analysis of Deviance Table
 Cox model: response is  Surv(futime, fustat)
 Model 1: ~ resid.ds + rx + ecog.ps
 Model 2: ~ resid.ds * rx + ecog.ps
   loglik  Chisq Df P(>|Chi|) 
1 -31.970                    
2 -30.946 2.0469  1    0.1525

This is an LR test.

w.r.t. the comment. A "null model" in Cox regression would be formed with only a 1 on the RHS of the formula-tilde:

fit <- coxph(Surv(futime, fustat) ~ 1, data = ovarian)

Upvotes: 11

EDi
EDi

Reputation: 13280

LR-Test is returned by default by coxph() from thr survival package (see last line):

require(survival)
test1 <- list(time=c(4,3,1,1,2,2,3), 
              status=c(1,1,1,0,1,1,0), 
              x=c(0,2,1,1,1,0,0), 
              sex=c(0,0,0,0,1,1,1)) 
# Fit a stratified model 
coxph(Surv(time, status) ~ x + strata(sex), test1) 

Call:
coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)


   coef exp(coef) se(coef)     z    p
x 0.802      2.23    0.822 0.976 0.33

Likelihood ratio test=1.09  on 1 df, p=0.297  n= 7, number of events= 5 

Upvotes: 2

Related Questions