2025-01-12 00:52:51 +08:00

50 lines
1.5 KiB
Plaintext

R Under development (unstable) (2023-05-10 r84417) -- "Unsuffered Consequences"
Copyright (C) 2023 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.
> 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
0.920 0.070 0.981