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?
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).
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.