Density, distribution, quantile, hazard, cumulative hazard, and restricted mean survival time functions for the M-spline baseline hazards model.
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)
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.
Vector of quantiles
M-spline basis produced by splines2::mSpline()
Vector (or matrix) of spline coefficients with length (or number
of columns) equal to the dimension of basis
Vector of rate parameters
Logical; if TRUE
, probabilities p
are given as
\(\log(p)\)
Logical; if TRUE
(the default), probabilities are
\(P(X \le x)\), otherwise \(P(X > x)\)
Vector of probabilities
Vector of times to which the restricted mean survival time is calculated
Optional left-truncation time or times. The returned restricted mean survival will be conditioned on survival up to this time
Survival models with a flexible M-spline on the baseline hazard are described by Brilleman2020;textualmultinma. 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
Royston2013;textualmultinma.
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
).