rlr {rolr} | R Documentation |
Calculating Running Logrank Test
Description
rlr
is used to calculate a logrank test for every two groups
obtained from dichotomizing a continuous covariate x at a particular point.
It will examine all values in x except the first and last ns
points.
Usage
rlr(times, status, x, ns = 15, trend = "decrease", method = "approximate")
Arguments
times |
Survival outcome. |
status |
Censoring indicator which takes 1 when an event occurs at the end of a study and 0 otherwise. |
x |
A continuous covariate. |
ns |
Minimum number of subjects in each group, whether it is the group
with |
trend |
A character that takes either |
method |
A character that takes either |
Details
When the association is positive, that is, larger covariate values
leading to worse survival, and you enter trend = "decrease"
, the test
statistics will be positive, but if you enter trend = "increase"
the
test statistics will be negative. Opposite is true when the association
is negative. You want to make sure to enter the option so that the
resulting test statistics are positive.
Value
A matrix of four columns as the following -
xcutoff - All cutpoints that have been used to dichotomize the sample
(that is, all values of the covariate x except the first and last ns
points)
L - Numerators of the logrank z tests for all cutpoints considered.
V - Denominators of the logrank z tests for all cutpoints considered.
logrank.stat - The logrank z tests for all cutpoints considered.
References
See main package help page.
Examples
library(rolr)
##### -------- Example 1
#simulate survival where hazard increases as covariate increases
d=simdata(nn = 150, hr.linear = 2, hazard.func = "linear", censoring.rate = 0)
#using trend = 'decrease', the test statistics are positive, which is good
res=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='decrease')
head(res)
#do it again with trend = 'increase', now the test statistics are negative.
#So you want to switch to trend='decrease'.
res2=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='increase')
head(res2)
#Note that the test statistics are the same except the signs
res[,'logrank.stat']+res2[,'logrank.stat']
#do it with exact method, how close is it to the approximate method?
res3=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='decrease',
method="exact")
cor(res[,'logrank.stat'], res3[,'logrank.stat'])
##### -------- Example 2
#Simulate survival where hazard decreases as covariate increases
d=simdata(nn = 150, hr.linear = 1/3, hazard.func = "linear", censoring.rate = 0)
#using trend = 'decrease', and the test statistics are negative, which
#is not good
res=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='decrease')
head(res)
#do it again with trend = 'increase', now the test statistics are positive,
#which is good
res2=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='increase')
head(res2)
#Note that the test statistics are the same except the signs
res[,'logrank.stat']+res2[,'logrank.stat']
#do it with exact method, how close is it to the approximate method?
res3=rlr(times=d$times, status=d$status, x=d$x, ns=15, trend='increase',
method="exact")
cor(res[,'logrank.stat'], res3[,'logrank.stat'])