HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Program Files/R/R-4.4.0/library/survival/tests/update.R
library(survival)

# the way a +cluster() term is handled in coxph has implications for update.

fit1 <- coxph(Surv(time, status) ~ age, cluster= inst, lung)
fit2 <- coxph(Surv(time, status) ~ age + cluster(inst), lung)
all.equal(fit1, fit2)

fit3 <- coxph(Surv(time, status) ~ age + sex + cluster(inst), lung)

test1 <- update(fit1, .~ .+ sex)
all.equal(test1, fit3)

# Gives a spurious warning message
test2 <- update(fit1, . ~ age + sex + cluster(inst), lung)
all.equal(test2, fit3)