Estimate restricted mean survival time (RMST) up to a user-specified follow-up time. RMST is the average survival time observed within a fixed time window, such as 365 days.
Arguments
- data
A
data.framecontaining survival time and event status.- time
Survival follow-up time. Quoted and bare names are accepted.
- event
Event indicator. Quoted and bare names are accepted. Numeric
0/1, numeric1/2, logical, character, and factor variables are accepted. For two-level character or factor variables, the second level is treated as the event.- by
Optional grouping variable for separate RMST estimates. Quoted and bare names are accepted.
- tau
Restriction time for RMST. For example,
tau = 365reports mean survival time restricted to the first 365 days of follow-up.- digits
Number of digits for displayed survival time summaries.
- conf.level
Confidence level for RMST confidence intervals.
- format
Output format. One of
"flextable"(default),"gt", or"tibble".- theme
Table styling preset.
Value
A list of class c("gtregression","rmst_table", ...) with
elements:
tableA
flextable,gt_tbl, orNULLwhenformat = "tibble".table_bodyTibble with numeric RMST summaries.
table_displayDisplay data frame used to render the table.
fitFitted
survfitobject.time,event,by,tau,format,sourceMetadata fields.
Details
RMST is estimated from survival::survfit() using Kaplan-Meier methods
and summary.survfit(rmean = tau). When by has exactly two
groups, the table includes the RMST difference as the second group minus the
first group, with a Wald confidence interval and p-value based on the
reported RMST standard errors.
Examples
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
labels = c("Standard", "Test"))
rmst_table(
data = lung_data,
time = time,
event = status,
by = trt,
tau = 365
)
rmst_table(
data = lung_data,
time = "time",
event = "status",
tau = 180,
format = tibble
)
#> # A tibble: 1 × 14
#> Type Group Tau N Events RMST SE CI.lower CI.upper Difference
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Group Overall 180 137 128 88.5 5.64 77.5 99.6 NA
#> # ℹ 4 more variables: Difference.SE <dbl>, Difference.CI.lower <dbl>,
#> # Difference.CI.upper <dbl>, p.value <dbl>