Re: [R] Trend test for survival data

From: Terry Therneau <therneau_at_mayo.edu>
Date: Tue, 22 Apr 2008 07:52:16 -0500 (CDT)


> Hello,
> is there a R package that provides a log rank trend test
> for survival data in >=3 treatment groups?
> Or are there any comparable trend tests for survival data in R?

  The log-rank test is equivalent to a Cox model with a factor variable as the predictor. To do a trend test, simply fit the Cox model with the variable scored as 1,2,3,... Or fit it as a factor and do a post-hoc trend test:   

> fit1 <- coxph(Surv(time, status) ~ ph.ecog, data=lung)
> fit1

Call:
coxph(formula = Surv(time, status) ~ ph.ecog, data = lung)

         coef exp(coef) se(coef)   z       p
ph.ecog 0.476      1.61    0.113 4.2 2.7e-05

Likelihood ratio test=17.6 on 1 df, p=2.77e-05 n=227 (1 observation deleted due to missingness)

> fit2 <- coxph(Surv(time, status) ~ factor(ph.ecog), data=lung)
> fit2

                  coef exp(coef) se(coef)    z       p
factor(ph.ecog)1 0.369      1.45    0.199 1.86 6.3e-02
factor(ph.ecog)2 0.916      2.50    0.225 4.08 4.5e-05
factor(ph.ecog)3 2.208      9.10    1.026 2.15 3.1e-02

Likelihood ratio test=18.4 on 3 df, p=0.000356 n=227 (1 observation deleted due to missingness)

> zz <- c(1,2,3)
> test.num <- zz %*% coef(fit2)
> test.var <- zz %*% fit2$var %*% zz
> test.num/sqrt(test.var)

        [,1]
[1,] 2.74323

  Note that ecog performace score=0 is implicitly part of the contrast. The full coefficient vector is (0, .369, .916, 2.208) and my linear contrast zz is 0,1,2,3.   

          Terry Therneau



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 22 Apr 2008 - 12:58:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Apr 2008 - 13:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive