mean.survextrap {survextrap} | R Documentation |
Mean survival time
Description
Compute the mean survival time from a model fitted with
survextrap
. Defined as the integral of the fitted
survival curve from zero to infinity. This relies on numerical
integration, which is done for every parameter in the MCMC sample,
so it may be slow.
Usage
## S3 method for class 'survextrap'
mean(
x,
newdata = NULL,
newdata0 = NULL,
wane_period = NULL,
wane_nt = 10,
disc_rate = 0,
niter = NULL,
summ_fns = NULL,
sample = FALSE,
...
)
Arguments
x |
A fitted model object as returned by |
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. |
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 |
... |
Other options (currently unused). |
Details
Additionally for some models, the integration up to infinity may
not converge, giving an error message. This typically occurs if
there is a substantial probability of high survival times or zero
hazards at later times. The restricted mean survival time can
usually be computed in these situations with rmst
,
but the model should also be investigated to ensure the posterior
distributions are realistic, and simplified or supplemented with
external data or informative priors if appropriate.
Value
A data frame with each row containing posterior summary statistics for a particular covariate value.
An attribute "sample"
is also returned, containing a matrix
of samples from the posterior distribution of the RMST.