rmst {survextrap} | R Documentation |
Restricted mean survival time
Description
Compute the restricted mean survival time from a model fitted with
survextrap
. Defined as the integral of the fitted
survival curve up to a specified time.
Usage
rmst(
x,
t,
newdata = NULL,
newdata0 = NULL,
wane_period = NULL,
wane_nt = 10,
disc_rate = 0,
method = "gl",
gl_nodes = 100,
niter = NULL,
summ_fns = NULL,
sample = FALSE
)
Arguments
x |
A fitted model object as returned by |
t |
Vector of times. The restricted mean survival time up to each one of these times will be computed. |
newdata |
Data frame of covariate values to compute the output for. If there are covariates in the model and this is not supplied, the following default is used: (a) if the only covariate is one factor variable, then the output is computed for each level of this factor. (b) if there are multiple covariates, or any numeric covariates, then the output is computed at the mean of each numeric covariate in the original data, and at the baseline level of each factor covariate. Note: caution is required about how treatment groups (for example)
are stored in your data. If these are coded as numeric (0/1),
then if |
newdata0 |
Data frame of covariate values defining the "untreated" group
for use in treatment waning models. See |
wane_period |
Vector of two numbers, defining the time period over which
the hazard is interpolated between the hazard of the "treated" group (taken from |
wane_nt |
Number of intervals defining the piecewise constant approximation to the hazard during the waning period. |
disc_rate |
Discounting rate used to calculate the discounted mean or restricted mean survival time, using an exponential discounting function. |
method |
Method of numerical integration to obtain the restricted mean survival time from the survival function. The default is
|
gl_nodes |
Number of nodes for the Gauss-Legendre method. |
niter |
Number of MCMC iterations to use to compute credible intervals. Set to a low value to make this function quicker, at the cost of some approximation error (which may not be important for plotting or model development). |
summ_fns |
A list of functions to use to summarise the posterior sample.
This is passed to |
sample |
If |
Value
A data frame (tibble) with each row containing posterior summary statistics for a particular time and covariate value.
Or if sample=TRUE
, an array with dimensions
length(t)
, niter
, nrow(newdata)
, giving the
RMST evaluated at different times, MCMC iterations and covariate
values respectively.
Examples
mod <- survextrap(Surv(years, status) ~ rx, data=colons, fit_method="opt")
rmst(mod, t=3, niter=100)
rmst(mod, t=3, summ_fns=list(mean=mean), niter=100)