Skip to contents

survestimand fits survival models from several R packages through one function and returns every fit as the same kind of object. From a fit it estimates survival and restricted mean survival time (RMST) by arm and the differences between arms, cumulative incidence under competing risks, and pseudo-observation regressions, each with an interval.

Installation

install.packages("survestimand",
                 repos = c("https://max578.r-universe.dev",
                           "https://cloud.r-project.org"))

The development version is on GitHub:

# install.packages("pak")
pak::pak("max578/survestimand")

survestimand needs only survival and S7. flexsurv, flexsurvcure, coxme and icenReg are optional: the parametric, spline and cure methods need flexsurv, and the default method, cox, needs only survival. A method that needs a missing package stops with an error naming the package to install.

Example

veteran (from survival) is a randomised trial of two chemotherapies in advanced lung cancer, with 137 patients. Fit a Cox model for treatment and the Karnofsky performance score:

library(survestimand)

v <- survival::veteran
v$trt <- factor(v$trt, levels = 1:2, labels = c("standard", "test"))

cx <- survestimand(survival::Surv(time, status) ~ trt + karno, v, method = "cox")
cx
#> <sest_fit> method = cox (cox, via survival)
#>   n = 137   events = 128
#>   power: ok (64.0 events/predictor)
#>   coefficients:
#> trttest   karno 
#>  0.1773 -0.0340

Next, the RMST to one year (365 days) in each arm, averaged over the covariates of all 137 patients, and the difference between arms. The interval is from a bootstrap that resamples within each arm:

sest_contrast(cx, v, arm = "trt", tau = 365, n_boot = 200L, seed = 1L)
#> <sest_contrast> cox, standardised; interval: bootstrap (200 replicates, seed 1)
#>   by arm:
#>  estimand time      arm estimate    se conf_low conf_high
#>      rmst  365 standard    122.4 12.08    97.42     146.0
#>      rmst  365     test    107.2 12.42    84.94     132.4
#> 
#>   contrasts against the reference arm:
#>  estimand time  arm reference estimate    se conf_low conf_high
#>      rmst  365 test  standard   -15.18 16.51   -44.04     16.82

The same contrast from a regression of each patient’s pseudo-observation for the RMST on arm and Karnofsky score (Andersen, Hansen and Klein, 2004), with a sandwich variance:

sest_pseudo(survival::Surv(time, status) ~ trt + karno, v, arm = "trt",
               type = "rmst", time = 365)
#> <sest_contrast> pseudo, pseudo-observation regression; interval: sandwich
#>   by arm:
#>  estimand time      arm estimate    se conf_low conf_high
#>      rmst  365 standard    117.2 12.53    92.68     141.8
#>      rmst  365     test    114.1 12.45    89.65     138.5
#> 
#>   contrasts against the reference arm:
#>  estimand time  arm reference estimate    se conf_low conf_high
#>      rmst  365 test  standard   -3.192 17.74   -37.97     31.59

The point estimates differ (-15.2 and -3.2 days), and both intervals include zero. The two rest on different assumptions. The Cox contrast assumes proportional hazards, which the Grambsch-Therneau test rejects for the Karnofsky score:

sest_ph_check(cx)$test
#>          term      chisq df      p_value
#> trt       trt  0.3071724  1 0.5794204939
#> karno   karno 11.9587841  1 0.0005439035
#> GLOBAL GLOBAL 13.5769295  2 0.0011266972

The pseudo-observation regression does not need proportional hazards, but it assumes that censoring does not depend on the covariates.

The vignette Arm contrasts, competing risks and manifests (vignette("orchestra-exemplar", package = "survestimand")) repeats this analysis with competing risks and with simulated data whose true effects are known.

What is in the package

Group Functions
Fitting survestimand() (fit any registered method), sest_tidy() (coefficients with hazard or time ratios and intervals), sest_curve() and predict() (predicted survival)
Estimands sest_rmst() (restricted mean survival time), sest_cuminc() (Aalen-Johansen cumulative incidence)
Arm contrasts and tests sest_contrast() (survival and RMST by arm), sest_cr_contrast() (cumulative incidence and time lost to a cause), sest_pseudo() (pseudo-observation regression), sest_logrank() (log-rank test, optionally stratified), sest_ph_check() (test of proportional hazards and the hazard ratio in time windows)
Piecewise-exponential models sest_split() (follow-up split into intervals for a Poisson model), sest_from_hazard_draws() (draws of interval hazards to draws of standardised survival, RMST and cumulative incidence)
Simulation sest_simulate() (recurrence and death simulated from a data set’s arms and covariates, with the true value of each estimand)
Model comparison and scoring sest_ic() (AIC and BIC), sest_stack() (stacks several event types per subject for a marginal Cox model), sest_score() (concordance, censoring-weighted Brier score), sest_power() (events-per-predictor check)
The method registry sest_methods(), sest_register(), sest_contract(), sest_validate_method()
Composition as_orchestra_manifest() methods (results written as manifests with a hash of their numbers; needs orchestraManifest), as_sest_manifest() and sest_manifest() (draws of parameters and predicted survival)
Refusals sest_refusal(), is_sest_refusal() (the result returned when a method cannot give an estimate, and a test for it)

sest_methods() lists the registered methods: Kaplan-Meier, Cox and ridge-penalised Cox; exponential, Weibull, gamma, generalised gamma, Gompertz, log-normal and log-logistic accelerated failure time models; Royston-Parmar splines; mixture cure; shared frailty; Fine-Gray and cause-specific hazards for competing risks; Andersen-Gill for recurrent events; and interval-censored regression.

Stability

survestimand is experimental and its interface may change before version 1.0.0. Every change that breaks existing code is listed in NEWS.md under a “Breaking changes” heading for the version that makes it.

  • survival provides Surv objects, Kaplan-Meier and Aalen-Johansen curves, Cox models and parametric accelerated failure time models.
  • flexsurv fits flexible parametric survival models, including Royston-Parmar splines and any user-defined distribution, and parametric multi-state models.
  • censored adds survival engines (parametric, semi-parametric and tree-based) to the parsnip modelling interface.

survestimand fits its models with survival and, when installed, flexsurv, flexsurvcure, coxme and icenReg, and adds arm contrasts, competing-risks contrasts, pseudo-observation regression and simulation.

Citation

citation("survestimand") gives:

Moldovan M (2026). survestimand: Survival Estimands from Many Models Through One Interface. https://github.com/max578/survestimand.

References

Andersen, P. K., Hansen, M. G., & Klein, J. P. (2004). Regression analysis of restricted mean survival time based on pseudo-observations. Lifetime Data Analysis, 10(4), 335-350. https://doi.org/10.1007/s10985-004-4771-0

Contributing

Bug reports and suggestions are welcome through the issue tracker.

Licence

MIT © Max Moldovan.