How one can create a logrank test for trend and does it differ from normal logrank test? Any suggestions or literature? Maybe some R examples and functions?
Asked
Active
Viewed 3,872 times
5
-
Could you elaborate your hypothesis, e.g. by a formula? – Horst Grünbusch Aug 20 '14 at 10:04
-
3To add to that it is important to state what type of variable you wish to associate with time-to-event. If it is an unordered categorical variable then the logrank test as it was originally proposed is a decent choice. There is no reason not to use its generalization the Cox PH model though. And don't fall for the commonly used "tests for trend" in which a continuous variable is split into quantile groups and the quantile group integers are treated as linear in the log hazard. This is a poorly fitting model if there ever was one. – Frank Harrell Jun 20 '15 at 18:44
-
Thanks @FrankHarrell, I will remember not to do this :) – Marcin Kosiński Jun 21 '15 at 13:15
2 Answers
3
Try comp
from survMisc
package. It extends the survival
package. It counts statistic and p-value for logrank test, as well as for Gehan-Breslow, Tarone-Ware, Peto-Peto and Fleming-Harrington tests and tests for trend (for all of the above mentioned). The example taken from the manual is the following:
data(larynx, package="KMsurv")
s4 <- survfit(Surv(time, delta) ~ stage, data=larynx)
comp(s4)
comp(s4)$tests$trendTests # outputs only the results for trend tests
If you compare the results with
survdiff(Surv(time, delta) ~ stage, data=larynx)
you get the same result for 'traditional' logrank test (not the trend test).

potockan
- 231
- 2
- 5
-
-
-
Have you noticed that the p-values from this package are in relations `p1=1-p2` of standard SAS output? Where p1 is p-value from R package, and p2 is p-value from SAS? – Marcin Kosiński Jun 24 '15 at 21:03
-
1Yes, I have noticed that. And sometimes the results are slightly different then these obtained from SAS. – potockan Jul 07 '15 at 09:41
-
-
It is, maybe sth isn't done correctly and someone should report it to the authors? – potockan Jul 07 '15 at 09:52
-
-
2
Your question is not very clear, so not sure if this is what you are looking for. To test the proportional hazards assumption you can use the Grambsch-Therneau test on Schoenfeld residuals of the proportional hazards model. This essentially tests the slope of (scaled) residuals as a function of follow-up time.

Marc Claesen
- 17,399
- 1
- 49
- 70