Compare restricted mean survival time between every pair of groups
Source:R/rmst-test.R
pairwise_rmst_test.Rdpairwise_rmst_test() runs rmst_test() on each pair of groups, using only the rows of the two
groups, and adjusts the p-values for the number of comparisons.
Arguments
- formula
A formula with a
Surv()response on the left and the grouping variables on the right, such asSurv(time, status) ~ celltype. Astrata()term stratifies each 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".- correction
The adjustment for multiple comparisons:
"holm"(the default),"bh"(Benjamini-Hochberg),"bonferroni", or"none".- conf_level
The confidence level, between 0 and 1. The default is
0.95.
Value
A data frame with one row per pair of groups, in the order of the groups: group1,
group2, rmst1, rmst2, estimate, std_error, conf_low, conf_high, statistic,
p_value (unadjusted), and p_adjusted.
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),
ecog = c(0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2)
)
pairwise_rmst_test(Surv(time, status) ~ ecog, data = lung, tau = 500)
#> group1 group2 rmst1 rmst2 estimate std_error conf_low conf_high statistic
#> 1 0 1 248.0 371.5 -123.5 70.52172 -261.7200 14.72002 -1.7512336
#> 2 0 2 248.0 429.5 -181.5 68.47399 -315.7066 -47.29344 -2.6506415
#> 3 1 2 371.5 429.5 -58.0 87.97727 -230.4323 114.43228 -0.6592612
#> p_value p_adjusted
#> 1 0.079905679 0.15981136
#> 2 0.008033908 0.02410172
#> 3 0.509728057 0.50972806