Generic function to find the quantiles of a distribution, given the equivalent probability distribution function.
Arguments
- pdist
Probability distribution function, for example,
pnormfor 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)==0for \(x<0\).- p
Vector of probabilities to find the quantiles for.
- 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 argumentsgammaandknotsinqsurvspline.- scalarargs
Character vector naming scalar arguments of the distribution function that cannot be vectorised. This is used for the arguments
scaleandtimescaleinqsurvspline.- ...
The remaining arguments define parameters of the distribution
pdist. These MUST be named explicitly.This may also contain the standard arguments
log.p(logical; defaultFALSE, ifTRUE, probabilities p are given as log(p)), andlower.tail(logical; ifTRUE(default), probabilities are P[X <= x] otherwise, P[X > x].).If the distribution is bounded above or below, then this should contain arguments
lboundanduboundrespectively, and these will be returned ifpis 0 or 1 respectively. Defaults to-InfandInfrespectively.
Details
This function is used by default for custom distributions for which a quantile function is not provided.
It works by finding the root of the equation \(h(q) = pdist(q) - p = 0\).
Starting from the interval \((-1, 1)\), the interval width is expanded by
50% until \(h()\) is of opposite sign at either end. The root is then
found using uniroot.
This assumes a suitably smooth, continuous distribution.