4

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

Dr Vicki
  • 115
  • 1
  • 1
  • 6

2 Answers2

10

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)
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • In the above case, which Model is the null model? Thank you. – NickBraunagel Jan 20 '17 at 19:07
  • 1
    I would call Model 1 the "base" model. I reserve the term "null model" for those which have just an "intercept" on the RHS. Model 2 (`=fit`) in this case has the extra term formed by the interaction which is 1 in cases where both `resid.ds` and `rx` are not the base factor level. – IRTFM Jan 21 '17 at 01:20
2

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 
EDi
  • 13,160
  • 2
  • 48
  • 57