MyNixOS website logo
Description

Time-Varying Restricted Mean Survival Time from Survival Matrices.

Utilities for restricted mean survival time (RMST) and time-varying restricted mean survival time quantities computed from survival curves provided on a time grid. The package is model-agnostic and accepts only a time vector and survival matrices, returning RMST-based quantities and bootstrap summaries. For restricted mean survival time methodology, see Royston and Parmar (2013) <doi:10.1186/1471-2288-13-152>.

tvrmst

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.

Motivation

Restricted mean survival time (RMST) is defined as

$$ \mathrm{RMST}(\tau) = \int_0^\tau S(u),du. $$

RMST is often more interpretable and robust than hazard ratios, especially under non-proportional hazards. Most implementations target a single horizon $\tau$. tvrmst extends this to the full dynamic curve:

$$ \tau \mapsto \mathrm{RMST}(\tau). $$

This enables:

  • Continuous-time treatment contrasts

  • Time-dependent benefit visualization

  • Individual-level RMST trajectories

Mathematical Framework

For subject $i$, with predicted survival $S_i(t)$:

$$ \mathrm{RMST}_i(\tau) = \int_0^\tau S_i(u),du. $$

Population mean dynamic RMST:

$$ \mathrm{RMST}(\tau) = \frac{1}{n}\sum_{i=1}^{n}\mathrm{RMST}_i(\tau). $$

Two-arm contrast (A vs B):

$$ \Delta(\tau) = \mathrm{RMST}_B(\tau) - \mathrm{RMST}_A(\tau). $$

All integrals use deterministic trapezoidal integration on a common time grid.

Design Principles

  1. Matrix-first abstraction: rows are subjects, columns are time points.

  2. Model-agnostic workflow: works with any upstream survival estimator.

  3. Unbalanced-arm support: group sizes can differ.

tvrmst does not fit survival models.

Installation

# install.packages("remotes")
remotes::install_github("your-username/tvrmst")

Core API

Data structure

  • as_survmat()
  • nobs_survmat()
  • bind_survmat()

Estimands

  • rmst_dynamic()
  • rmst_delta()

Bootstrap

  • bootstrap_curve()
  • boot_rmst_delta()

Visualization

  • plot_rmst_individual_by_group()
  • plot_rmst_two_arms()
  • plot_delta_curve()
  • plot_boot_curve()

Coercion helper

  • as_survprob_matrix()

Basic Workflow

1) Prepare two-arm survival matrices

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)

2) Dynamic RMST

res_all <- rmst_dynamic(x_all)

Key outputs:

  • res_all$individual: subject-level dynamic RMST curves

  • res_all$mean: population mean dynamic RMST curve

3) Two-arm contrast

d <- rmst_delta(xA, xB)

Returns full $\Delta(\tau)$ over the grid.

4) Bootstrap confidence intervals

boot <- boot_rmst_delta(xA, xB, R = 300, seed = 1)

Computes percentile confidence bands pointwise along the delta curve.

Visualization

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)

Relation to Existing RMST Workflows

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

citation("tvrmst")

License

MIT.

Metadata

Version

0.0.6

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows