rmst_test() compares the restricted mean survival time (RMST) up to tau of two groups. The
RMST is the area under the Kaplan-Meier curve on \([0, \tau]\) (see rmst()). The comparison
is a Wald test of the difference, the ratio, or the percentage difference between the first
group and the second. Unlike the hazard ratio, the RMST difference doesn't depend on
proportional hazards and reads directly as time gained or lost.
Arguments
- formula
A formula with a
Surv()response on the left and a grouping variable on the right, such asSurv(time, status) ~ sex. Astrata()term, such asSurv(time, status) ~ sex + strata(ph.ecog), stratifies the comparison.- data
A data frame holding the variables in
formula.- tau
The end of the window for the restricted mean.
- subset
An optional expression selecting the rows of
datato use.- na.action
What to do with rows that have missing values. The default drops them.
- estimand
What to compare:
"difference"(the default),"ratio", or"percentage_difference".- conf_level
The confidence level, between 0 and 1. The default is
0.95.
Value
rmst_test() gives an rmst_test object with the estimate, its std_error,
conf_low, conf_high, the Wald statistic, the two-sided p_value, method, the two groups' labels (group1 and group2), their RMSTs and standard
errors (rmst1, se1, rmst2, and se2), tau, estimand, stratified, and
conf_level. as.data.frame() gives it as a one-row data frame.
rmst_diff() gives that one-row data frame for the difference directly: group1, group2,
rmst1, rmst2, difference, std_error, conf_low, conf_high, statistic, and
p_value.
Details
With standard errors \(s_1\) and \(s_2\) of the two groups' RMSTs \(r_1\) and \(r_2\), the difference \(r_1 - r_2\) has standard error \(\sqrt{s_1^2 + s_2^2}\). The ratio \(r_1 / r_2\) is tested on the log scale, where the delta method gives the standard error \(\sqrt{(s_1 / r_1)^2 + (s_2 / r_2)^2}\), and its confidence limits are exponentiated. The reported standard error of the ratio itself is that times the ratio. The percentage difference is \(100 (r_1 - r_2) / r_2\), with the standard error of the difference scaled by \(100 / r_2\).
A strata() term on the right-hand side gives a stratified comparison. Within each stratum
that holds both groups, the two RMSTs and the variance of their difference \(v_s\) are
computed, and the strata are pooled with weights \(w_s = 1 / v_s\). The pooled difference has
variance \(1 / \sum w_s\), and the pooled RMSTs reported for each group use the same weights.
See also
pairwise_rmst_test() for more than two groups.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2),
sex = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
)
rmst_test(Surv(time, status) ~ sex, data = lung, tau = 365)
#> <rmst_test> Surv(time, status) ~ sex
#> RMST difference (tau = 365)
#>
#> rmst std_error
#> sex=1 329.3333 23.49547
#> sex=2 265.0000 34.26855
#>
#> Difference (1 vs 2): 64.33, 95% CI [-17.1, 145.8]
#> z = 1.548, p = 0.122
rmst_test(Surv(time, status) ~ sex, data = lung, tau = 365, estimand = "ratio")
#> <rmst_test> Surv(time, status) ~ sex
#> RMST ratio (tau = 365)
#>
#> rmst std_error
#> sex=1 329.3333 23.49547
#> sex=2 265.0000 34.26855
#>
#> Ratio (1 vs 2): 1.243, 95% CI [0.9304, 1.66]
#> z = 1.472, p = 0.141
rmst_diff(Surv(time, status) ~ sex, data = lung, tau = 365)
#> group1 group2 rmst1 rmst2 difference std_error conf_low conf_high
#> 1 1 2 329.3333 265 64.33333 41.54961 -17.10241 145.7691
#> statistic p_value
#> 1 1.54835 0.1215381