63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
|
|
R version 3.0.0 (2013-04-03) -- "Masked Marvel"
|
|
Copyright (C) 2013 The R Foundation for Statistical Computing
|
|
Platform: i686-pc-linux-gnu (32-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.
|
|
|
|
> #
|
|
> # Test out anova, with strata terms
|
|
> #
|
|
> options(na.action=na.omit)
|
|
> library(survival)
|
|
Loading required package: splines
|
|
>
|
|
> fit1 <- coxph(Surv(time, status) ~ ph.ecog + wt.loss + strata(sex) +
|
|
+ poly(age,3), lung)
|
|
> ztemp <- anova(fit1)
|
|
>
|
|
> tdata <- na.omit(lung[, c('time', 'status', 'ph.ecog', 'wt.loss', 'sex', 'age')])
|
|
> fit2 <- coxph(Surv(time, status)~ ph.ecog + wt.loss + poly(age,3) + strata(sex),
|
|
+ data=tdata)
|
|
> ztemp2 <- anova(fit2)
|
|
> all.equal(ztemp, ztemp2)
|
|
[1] TRUE
|
|
>
|
|
>
|
|
> fit2 <- coxph(Surv(time, status) ~ ph.ecog + wt.loss + strata(sex), tdata)
|
|
> fit3 <- coxph(Surv(time, status) ~ ph.ecog + strata(sex), tdata)
|
|
>
|
|
> all.equal(ztemp$loglik, c(fit1$loglik[1], fit3$loglik[2], fit2$loglik[2],
|
|
+ fit1$loglik[2]))
|
|
[1] TRUE
|
|
> all.equal(ztemp$Chisq[-1], 2* diff(ztemp$loglik))
|
|
[1] TRUE
|
|
> all.equal(ztemp$Df[-1], c(1,1,3))
|
|
[1] TRUE
|
|
>
|
|
> ztemp2 <- anova(fit3, fit2, fit1)
|
|
> all.equal(ztemp2$loglik, ztemp$loglik[-1])
|
|
[1] TRUE
|
|
> all.equal(ztemp2$Chisq[2:3], ztemp$Chisq[3:4])
|
|
[1] TRUE
|
|
> # Change from ztemp2$P; it's a data frame and in R 3.0.2 abbreviated names
|
|
> # give a warning
|
|
> all.equal(ztemp2[[4]][2:3], ztemp[[4]][3:4])
|
|
[1] TRUE
|
|
>
|
|
>
|
|
>
|
|
> proc.time()
|
|
user system elapsed
|
|
0.284 0.020 0.301
|