45 lines
1.5 KiB
Plaintext
Raw Normal View History

2025-01-12 00:52:51 +08:00
R Under development (unstable) (2018-04-09 r74565) -- "Unsuffered Consequences"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
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
0.692 0.036 0.727