quantile.density: Extract Quantiles from 'density' Objects

quantile.densityR Documentation

Extract Quantiles from 'density' Objects


Quantiles for objects of class density


## S3 method for class 'density'
quantile(x, probs = seq(0.25, 0.75, 0.25), names = TRUE, normalize = TRUE, ...)



a object of class density or a list of densities


numeric vector of probabilities with values in [0,1]. Note that elements very close to the boundaries return Inf or -Inf


logical; if TRUE, the result has a names attribute, resp. a rownames and colnames attributes. Set to FALSE for speedup with many probabilities


logical; if TRUE then the values in x$y are multiplied with a factor such that their integral is equal to one.


further arguments passed to or from other methods (currently unused)


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 \Sexpr[results=rd]{tools:::Rd_expr_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.


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.


Stefan Zeugner, stefan.zeugner@ec.europa.eu

Martin Feldkircher, martin.feldkircher@da-vienna.ac.at


  rNorm_dens <- density(rnorm(100000))

mvMonitoring documentation built on Nov. 22, 2023, 1:09 a.m.