R version 4.4.0 RC (2024-04-16 r86458 ucrt) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(survival) > # > # Check out intercept/interaction for Frank H > # > age2 <- lung$age - 50 > fit1 <- coxph(Surv(time, status) ~ age * strata(sex), lung) > fit2 <- coxph(Surv(time, status) ~ age2*strata(sex), lung) > > tdata <- data.frame(age=50:60, age2=0:10, sex=c(1,2,1,2,1,2,1,2,1,2,1)) > > surv1 <- survfit(fit1, tdata) > surv2 <- survfit(fit2, tdata) > # The call won't match, nor the newdata data frame > icall <- match(c("newdata", "call"), names(surv1)) > all.equal(unclass(surv1)[-icall], unclass(surv2)[-icall]) [1] TRUE > > > # It should match what I get with a single strata fit > > fit3 <- coxph(Surv(time, status) ~ age, data=lung, + init=fit1$coef[1], subset=(sex==1), iter=0) > surv1b <- survfit(fit3, newdata=list(age=c(50,52, 54))) > all.equal(c(surv1b$surv), surv1[c(1,3,5)]$surv) [1] TRUE > > > > > proc.time() user system elapsed 1.20 0.12 1.26