survextrap | R Documentation |
Flexible Bayesian parametric survival models. Individual data are represented using M-splines and a proportional hazards or flexible non-proportional hazards model. External aggregate data can be included, for example, to enable extrapolation outside the individual data. A fixed background hazard can also be included in an additive hazards (relative survival) model. Mixture cure versions of these models can also be used.
survextrap(
formula,
data = NULL,
external = NULL,
cure = FALSE,
nonprop = FALSE,
prior_hscale = p_normal(0, 20),
prior_loghr = NULL,
prior_hsd = p_gamma(2, 1),
prior_cure = p_beta(1, 1),
prior_logor_cure = NULL,
prior_hrsd = p_gamma(2, 1),
backhaz = NULL,
backhaz_strata = NULL,
mspline = NULL,
add_knots = NULL,
smooth_model = "random_walk",
hsd = "bayes",
coefs_mean = NULL,
fit_method = "mcmc",
loo = (fit_method == "mcmc"),
...
)
formula |
A survival formula in standard R formula syntax, with a call to Covariates included on the right hand side of the formula with be
modelled with proportional hazards, or if If |
data |
Data frame containing variables in This may be omitted, in which case |
external |
External data as a data frame of aggregate survival counts with columns named:
If there are covariates in |
cure |
If |
nonprop |
Non-proportional hazards model specification. This is achieved by modelling the spline basis coefficients in terms of the covariates. See the methods vignette for more details. If If this is a formula, then this is assumed to define a model for the dependence of the basis coefficients on the covariates. IF this is |
prior_hscale |
Prior for the baseline log hazard scale
parameter ( Note that "Baseline" is defined by the continuous covariates taking a value of zero and factor covariates taking their reference level. To use a different baseline, the data should be transformed appropriately beforehand, so that a value of zero has a different meaning. For continuous covariates, it helps for both computation and interpretation to define the value of zero to denote a typical value in the data, e.g. the mean. |
prior_loghr |
Priors for log hazard ratios. This should be a
call to The default is |
prior_hsd |
Gamma prior for the standard deviation that
controls the variability over time (or smoothness) of the hazard
function. This should be a call to |
prior_cure |
Prior for the baseline cure probability. This should be a
call to |
prior_logor_cure |
Priors for log odds ratios on cure probabilities.
This should be a call to |
prior_hrsd |
Prior for the standard deviation parameters that
smooth the non-proportionality effects over time in
non-proportional hazards models. This should be a call to
|
backhaz |
Background hazard, that is, for causes of death
other than the cause of interest. This defines a
"relative survival" or "additive hazards" model. The overall
hazard that describes the all-cause survival data (given in the
The background hazard is assumed to be known, and the cause-specific hazard is modelled with the flexible parametric model. The background hazard can be supplied in two forms. The meaning of predictions from the model depends on which of these is used. (a) A data frame with columns (b) The (quoted) name of a variable in the data giving the
background hazard. For censored cases, the exact value does not
matter. The predictions from If there is external data, and If there are stratifying variables specified in
If |
backhaz_strata |
A character vector of names of variables that
appear in This is If stratification is done, then |
mspline |
A list of control parameters defining the spline model.
If there are external data, and both
|
add_knots |
Any extra knots beyond those chosen from the
individual-level data (or supplied in |
smooth_model |
The default The alternative In non-proportional hazards models, setting |
hsd |
Smoothing variance parameter estimation.
Alternatively, if a number is supplied here, then the smoothing parameter is fixed to this number. |
coefs_mean |
Spline basis coefficients that define the prior
mean for the hazard function. By default, these are set to values
that define a constant hazard function (see
|
fit_method |
Method from rstan used to fit the model. If If If |
loo |
Compute leave-one-out cross-validation statistics.
This is done by default. Set to See the |
... |
Additional arguments to supply to control the Stan fit,
passed to the appropriate rstan function, depending on
which is chosen through the |
A list of objects defining the fitted model. These are not
intended to be extracted directly by users. Instead see
summary.survextrap
for summarising the parameter
estimates, and the functions hazard
,
survival
, rmst
and others for
computing interesting summaries of the fitted survival
distribution.
The object returned by rstan
containing samples from the fitted
model is returned in the stanfit
component. See the
rstan documentation. The
function get_draws
is provided to convert this to a
simple matrix of posterior samples with all chains collapsed.
Jackson, C. (2023) survextrap
: a package for flexible and transparent
survival extrapolation. BMC Medical Research Methodology 23:282.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1186/s12874-023-02094-1")}
Timmins I, Torabi F, Jackson C, Lambert P, Sweeting M J. (2025) Simulation-based assessment of a Bayesian survival model with flexible baseline hazard and time-dependent effects. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2503.21388")}.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.