Skip to contents

Density, distribution, quantile, hazard, cumulative hazard, and restricted mean survival time functions for the M-spline baseline hazards model.

Usage

dmspline(x, basis, scoef, rate, log = FALSE)

pmspline(q, basis, scoef, rate, lower.tail = TRUE, log.p = FALSE)

qmspline(p, basis, scoef, rate, lower.tail = TRUE, log.p = FALSE)

hmspline(x, basis, scoef, rate, log = FALSE)

Hmspline(x, basis, scoef, rate, log = FALSE)

rmst_mspline(t, basis, scoef, rate, start = 0)

Arguments

x, q

Vector of quantiles

basis

M-spline basis produced by splines2::mSpline()

scoef

Vector (or matrix) of spline coefficients with length (or number of columns) equal to the dimension of basis

rate

Vector of rate parameters

log, log.p

Logical; if TRUE, probabilities p are given as \(\log(p)\)

lower.tail

Logical; if TRUE (the default), probabilities are \(P(X \le x)\), otherwise \(P(X > x)\)

p

Vector of probabilities

t

Vector of times to which the restricted mean survival time is calculated

start

Optional left-truncation time or times. The returned restricted mean survival will be conditioned on survival up to this time

Value

dmspline() gives the density, pmspline() gives the distribution function (CDF), qmspline() gives the quantile function (inverse-CDF), hmspline() gives the hazard function, Hmspline() gives the cumulative hazard function, and rmst_mspline() gives restricted mean survival times.

Details

Survival models with a flexible M-spline on the baseline hazard are described by Brilleman et al. (2020) . Piecewise-exponential baseline hazards are a special case where the degree of the M-spline polynomial is 0.

The d/p/h/H functions are calculated from their definitions. qmspline() uses numerical inversion via flexsurv::qgeneric(). rmst_mspline()uses numerical integration via flexsurv::rmst_generic(), except for the special case of the piecewise-exponential hazard (i.e. degree 0 M-splines) which uses the explicit formula from Royston and Parmar (2013) .

Beyond the boundary knots, the hazard is assumed to be constant. (This differs from the approach in splines2::mSpline() that extrapolates the polynomial basis functions, which is numerically unstable and highly dependent on the data just before the boundary knots.) As with all extrapolation, care should be taken when evaluating the splines at times beyond the boundary knots (either directly through the d/p/h/H/rmst functions, or indirectly by requesting quantiles with qmspline() that correspond to times beyond the boundary knots). For this reason evaluating the (unrestricted) mean survival time is not generally recommended as this requires integrating over an infinite time horizon (i.e. rmst_mspline() with t = Inf).

References

Brilleman SL, Elci EM, Novik JB, Wolfe R (2020). “Bayesian Survival Analysis Using the rstanarm R Package.” arXiv. doi:10.48550/arXiv.2002.09633 , 2002.09633.

Royston P, Parmar MKB (2013). “Restricted mean survival time: an alternative to the hazard ratio for the design and analysis of randomized trials with a time-to-event outcome.” BMC Medical Research Methodology, 13(1). doi:10.1186/1471-2288-13-152 .