Smooth Survival Models, Including Generalized Survival Models
Overview
R implementation of generalized survival models (GSMs), smooth accelerated failure time (AFT) models and Markov multi-state models. For the GSMs, g(S(t|x))=eta(t,x) for a link function g, survival S at time t with covariates x and a linear predictor eta(t,x). The main assumption is that the time effect(s) are smooth doi:10.1177/0962280216664760. For fully parametric models with natural splines, this re-implements Stata's 'stpm2' function, which are flexible parametric survival models developed by Royston and colleagues. We have extended the parametric models to include any smooth parametric smoothers for time. We have also extended the model to include any smooth penalized smoothers from the 'mgcv' package, using penalized likelihood. These models include left truncation, right censoring, interval censoring, gamma frailties and normal random effects doi:10.1002/sim.7451, and copulas. For the smooth AFTs, S(t|x) = S_0(t*eta(t,x)), where the baseline survival function S_0(t)=exp(-exp(eta_0(t))) is modelled for natural splines for eta_0, and the time-dependent cumulative acceleration factor eta(t,x)=\int_0^t exp(eta_1(u,x)) du for log acceleration factor eta_1(u,x). The Markov multi-state models allow for a range of models with smooth transitions to predict transition probabilities, length of stay, utilities and costs, with differences, ratios and standardisation.
Install
Health
- OK13 OK2026-08-04
- NOTE12 OK, 1 NOTE2026-08-01
- OK12 OK2026-04-25
- NOTE12 OK, 2 NOTE2026-04-22
- ERROR11 OK, 2 NOTE, 1 ERROR2026-04-18
Show 1 earlier changeHide 1 earlier change
- NOTE12 OK, 2 NOTE2026-03-10
Documentation
- Help pages
- 35
- Examples that run
- 91%21 run in a plain check · 2 never run
- Exported functions with examples
- 75%
- Documented parameters
- 90%
- Return-value docs
- 100%
- Help pages citing references
- 80%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 147
- Median days to close, 50 most recently updated closed PRs
- 0
2 development-tooling and community-health practices detected across 2 families in the upstream repository
Checks run against github.com/mclements/rstpm2 on 2026-10-11.
Dependencies
Installing rstpm2 adds 8 packages (6 with compiled code, 4.5 MB of source tarballs). Heaviest: Rcpp 1.8 MB, RcppArmadillo 1.0 MB, mvtnorm 1.0 MB.
Show all 20 packagesHide all 20 packages
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- RR 4.6.0 released · 2026-04-24
- 1.7.1Latest
- 1.7.02025-08-27 · diff ↗
- 1.6.92025-07-25 · diff ↗
- 1.6.72025-05-11 · diff ↗
- RR 4.5.0 released · 2025-04-11
- 1.6.6.12024-12-21 · diff ↗
- 1.6.62024-10-29 · diff ↗
- 1.6.52024-08-20 · diff ↗
- 1.6.42024-08-19 · diff ↗
- RR 4.4.0 released · 2024-04-24
- 1.6.32023-12-05 · diff ↗ ·
removed 2 exports
aft_mixture, aft_integratedadded 2 exports
voptimize, voptimise - RR 4.3.0 released · 2023-04-21
- 1.6.22023-03-08 · diff ↗
- 1.6.1
- 1.5.92023-01-07 · diff ↗
Show 24 earlier eventsHide 24 earlier events
- 1.5.8
- 1.5.7
- 1.5.62022-05-10 · diff ↗
- RR 4.2.0 released · 2022-04-22
- 1.5.5
- RR 4.1.0 released · 2021-05-18
- 1.5.22021-03-03 · diff ↗
- RR 4.0.0 released · 2020-04-24
- 1.5.12019-11-06 · diff ↗
- 1.5.02019-10-15 · diff ↗ ·
added 10 exports
gsm, markov_msm, ratio_markov_msm, zeroModel, hrModel, aftModel, addModel, hazFun, splineFun, standardise - RR 3.6.0 released · 2019-04-26
- 1.4.52019-01-17 · diff ↗
- 1.4.4
- 1.4.2
- RR 3.5.0 released · 2018-04-23
- 1.4.12017-09-20 · diff ↗
- 1.4.0
- RR 3.4.0 released · 2017-04-21
- 1.3.4
- RR 3.3.0 released · 2016-05-03
- 1.3.22016-04-13 · diff ↗
- 1.3.12016-02-24 · diff ↗
- 1.2.22015-07-26
- RR 3.2.0 released · 2015-04-16
Package metadata
- First published
- 2015-07-26
- Total releases
- 28 / 11 yrs
- License
- GPL-2 | GPL-3 OSI
- Minimum R
- ≥ 3.0.2
- Bundled data
- 119 KB / 4 files
- Download size
- 1.1 MB
Cite
Cite this package
Run in R for the authors' entry:
citation("rstpm2")The package provides a citation file, so citation() returns the authors' own entry.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-18, which the citation names so these numbers can be found later. More on citing and the projects behind them.