R version 4.4.0 beta (2024-04-15 r86425 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. > # > # New tests 4/2010 to validate strata by covariate interactions > # > library(survival) > options(na.action=na.exclude) # preserve missings > options(contrasts=c('contr.treatment', 'contr.poly')) #ensure constrast type > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y)) > > tdata <- lung > tdata$sex <- lung$sex +3 > > # Both of these should produce warning messages about singular X, since there > # are ph.ecog=3 subjects in only 1 of the strata. > # Does not affect the test > fit1 <- coxph(Surv(time, status) ~ age + sex:strata(ph.ecog), lung) > fit2 <- coxph(Surv(time, status) ~ age + sex:strata(ph.ecog), tdata) > > aeq(fit1$coef, fit2$coef) [1] TRUE > aeq(fit1$var, fit2$var) [1] TRUE > aeq(predict(fit1), predict(fit2)) [1] TRUE > > proc.time() user system elapsed 1.07 0.14 1.20