1library(survey)
2library(survival)
3set.seed(2021-6-25)
4test1 <- list(time=c(4,3,1,1,2,2,3),
5              status=c(1,1,1,0,1,1,0),
6              x1=as.factor(rbinom(7, 2, 0.5)),
7              x=c(0,2,1,1,1,0,0))
8# Fit a stratified model
9mod_c <- coxph(Surv(time, status) ~ x1 + x, test1)
10mod_d <- coxph(Surv(time, status) ~ x + x1, test1)
11stopifnot(all.equal(regTermTest(mod_c, ~x1, df = Inf)[c("chisq","df","test.terms","p")],
12regTermTest(mod_d, ~x1, df = Inf)[c("chisq","df","test.terms","p")]))
13