File: anova.Rout.save

package info (click to toggle)
survival 2.36-14-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,500 kB
  • sloc: asm: 7,352; ansic: 5,369; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

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
> all.equal(ztemp2$P[2:3], ztemp$P[3:4])
[1] TRUE
> 
> 
>