Skip to contents

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


  newdata = NULL,
  newdata0 = NULL,
  wane_period = NULL,
  wane_nt = 10,
  niter = NULL,
  summ_fns = NULL,
  sample = FALSE



A fitted model object as returned by survextrap


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


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.


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


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.


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


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).


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.


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


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.


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.