Generic function to find restricted mean survival time for some distribution
Source:R/utils.R
rmst_generic.Rd
Generic function to find the restricted mean of a distribution, given the equivalent probability distribution function, using numeric integration.
Arguments
- pdist
Probability distribution function, for example,
pnorm
for the normal distribution, which must be defined in the current workspace. This should accept and return vectorised parameters and values. It should also return the correct values for the entire real line, for example a positive distribution should havepdist(x)==0
for \(x<0\).- t
Vector of times at which rmst is evaluated
- start
Optional left-truncation time or times. The returned restricted mean survival will be conditioned on survival up to this time.
- matargs
Character vector giving the elements of
...
which represent vector parameters of the distribution. Empty by default. When vectorised, these will become matrices. This is used for the argumentsgamma
andknots
inpsurvspline
.- scalarargs
Character vector naming scalar arguments of the distribution function that cannot be vectorised. This is used, for example, for the arguments
scale
andtimescale
inpsurvspline
.- ...
The remaining arguments define parameters of the distribution
pdist
. These MUST be named explicitly.
Details
This function is used by default for custom distributions for which an
rmst
function is not provided.
This assumes a suitably smooth, continuous distribution.
Examples
rmst_lnorm(500, start=250, meanlog=7.4225, sdlog = 1.1138)
#> [1] 237.8849
rmst_generic(plnorm, 500, start=250, meanlog=7.4225, sdlog = 1.1138)
#> [1] 237.8849
# must name the arguments