source("http://192.38.117.59/~linearpredictors/datafiles/readCsl.R") library(survival) ## ascites present? csl$ascites <- csl$asc #ifelse(csl$asc != "0", 1, 0) levels(csl$ascites) <- c("0","1","1") ## placebo as reference group csl$tment <- relevel(csl$tment, ref = "1") ## no need to make dummy variables full <- coxph(Surv(days, dc == 1) ~ sex + ascites:sex + ascites:sex:tment, data = csl) summary(full) noAscInt <- coxph(Surv(days, dc == 1) ~ sex + ascites:sex + sex:tment, data = csl) summary(noAscInt) noSexInt <- coxph(Surv(days, dc == 1) ~ sex + ascites:sex + ascites:tment, data = csl) summary(noSexInt) noInt <- coxph(Surv(days, dc == 1) ~ sex + ascites:sex + tment, data = csl) summary(noInt) ## the LR tests can be carried out like this: LR <- summary(full)$loglik[2]*2 - summary(noAscInt)$loglik[2]*2 ## we drop 2 coefficients, so df=2 1-pchisq(LR, df=2)