Skip to contents

Compute the difference in the restricted mean survival times between two covariate values (e.g. treatment groups).

Usage

irmst(
  x,
  t,
  newdata = NULL,
  newdata0 = NULL,
  wane_period = NULL,
  wane_nt = 10,
  niter = NULL,
  summ_fns = NULL,
  sample = FALSE,
  disc_rate = 0
)

Arguments

x

A fitted model object as returned by survextrap

t

Vector of times. The restricted mean survival time up to each one of these times will be computed.

newdata

A data frame with two rows. The result will be the restricted mean for the covariates in the second row, minus the restricted mean for the covariates in the first row. If newdata is omitted for models where the only covariate is a factor with two levels, then this is taken from these levels. Otherwise newdata must be supplied explicitly.

newdata0

Data frame of covariate values defining the "untreated" group for use in treatment waning models. See Survmspline_wane.

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 newdata) and the hazard of the "untreated" group (taken from newdata0). Optional - if this is not supplied, then no waning is assumed.

wane_nt

Number of intervals defining the piecewise constant approximation to the hazard during the waning period.

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 posterior::summarise_draws. By default this is list(median=median, ~quantile(.x, probs=c(0.025, 0.975))). If the list is named, then the names will be used for the columns of the output.

sample

If TRUE then an MCMC sample is returned from the posterior of the output, rather than summary statistics.

disc_rate

Discounting rate used to calculate the discounted mean or restricted mean survival time, using an exponential discounting function.

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 incremental RMST evaluated at different times, MCMC iterations and covariate values respectively.

Details

The posterior distribution is obtained by calling rmst for each group, obtaining each posterior sample from the "sample" attribute, and taking the difference to get a posterior sample for the difference.