quantile.density {mvMonitoring} | R Documentation |
Extract Quantiles from 'density' Objects
Description
Quantiles for objects of class density
Usage
## S3 method for class 'density'
quantile(x, probs = seq(0.25, 0.75, 0.25), names = TRUE, normalize = TRUE, ...)
Arguments
x |
a object of class |
probs |
numeric vector of probabilities with values in [0,1]. Note that
elements very close to the boundaries return |
names |
logical; if |
normalize |
logical; if |
... |
further arguments passed to or from other methods (currently unused) |
Details
This function is a near-exact copy of the quantile.density
function from package BMS (https://CRAN.R-project.org/package=BMS).
In spring of 2022, CRAN informed us that the BMS has been orphaned, so we
copied the code (and corresponding documentation) we needed from it. See
doi:10.18637/jss.v068.i04 for their paper.
The function quantile.density()
applies generically to the built-in
class density
(as least for versions where there is no such method
in the pre-configured packages). Note that this function relies on
trapezoidal integration in order to compute the cumulative densities
necessary for the calculation of quantiles.
Value
If x is of class density
(or a list with exactly one element),
a vector with quantiles. If x is a list of densities, then the output is a
matrix of quantiles, with each matrix row corresponding to the respective
density.
Author(s)
Stefan Zeugner, stefan.zeugner@ec.europa.eu
Martin Feldkircher, martin.feldkircher@da-vienna.ac.at
Examples
rNorm_dens <- density(rnorm(100000))
quantile(rNorm_dens)