Time-Varying Restricted Mean Survival Time from Survival Matrices
tvrmst is a matrix-first framework for computing dynamic restricted
mean survival time (RMST) curves, treatment contrasts, and bootstrap
confidence intervals.
The package separates survival estimation from functional summarization and operates directly on subject-level survival probability matrices.
Restricted mean survival time (RMST) is defined as
RMST is often more interpretable and robust than hazard ratios,
especially under non-proportional hazards. Most implementations target a
single horizon tvrmst extends this to the full dynamic curve:
This enables:
-
Continuous-time treatment contrasts
-
Time-dependent benefit visualization
-
Individual-level RMST trajectories
For subject
Population mean dynamic RMST:
Two-arm contrast (A vs B):
All integrals use deterministic trapezoidal integration on a common time grid.
-
Matrix-first abstraction: rows are subjects, columns are time points.
-
Model-agnostic workflow: works with any upstream survival estimator.
-
Unbalanced-arm support: group sizes can differ.
tvrmstdoes not fit survival models.
# install.packages("remotes")
remotes::install_github("your-username/tvrmst")as_survmat()nobs_survmat()bind_survmat()
rmst_dynamic()rmst_delta()
bootstrap_curve()boot_rmst_delta()
plot_rmst_individual_by_group()plot_rmst_two_arms()plot_delta_curve()plot_boot_curve()
as_survprob_matrix()
library(tvrmst)
set.seed(1)
time <- seq(0, 5, by = 0.05)
nA <- 100
nB <- 80
lambdaA <- rexp(nA, rate = 0.2)
lambdaB <- rexp(nB, rate = 0.15)
S_A <- outer(lambdaA, time, function(l, t) exp(-l * t))
S_B <- outer(lambdaB, time, function(l, t) exp(-l * t))
xA <- as_survmat(S_A, time, group = rep("A", nA))
xB <- as_survmat(S_B, time, group = rep("B", nB))
x_all <- bind_survmat(xA, xB)res_all <- rmst_dynamic(x_all)Key outputs:
-
res_all$individual: subject-level dynamic RMST curves -
res_all$mean: population mean dynamic RMST curve
d <- rmst_delta(xA, xB)Returns full
boot <- boot_rmst_delta(xA, xB, R = 300, seed = 1)Computes percentile confidence bands pointwise along the delta curve.
plot_rmst_individual_by_group(res_all, group = x_all$group)plot_rmst_two_arms(xA, xB)plot_delta_curve(d$time, d$delta)plot_boot_curve(boot)Compared with fixed-horizon RMST tools, tvrmst provides:
- Continuous dynamic RMST curves
- Individual RMST trajectories
- Direct compatibility with ML survival predictions
- A clean separation between model fitting and functional summarization
This supports modern benchmarking and production survival pipelines.
citation("tvrmst")MIT



