quantile.density {BMS}R Documentation

Extract Quantiles from 'density' Objects


Quantiles for objects of class "density", "pred.density" or "coef.density"


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

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

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



a object of class pred.density, coef.density, density, or a list of densities.


numeric vector of probabilities with values in [0,1] - 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 probs.


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.


The methods quantile.coef.density and quantile.pred.density both apply quantile.density to densities nested with object of class coef.density or pred.density.
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 quantile.density 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 with more than one element (e.g. as resulting from pred.density or coef.density), then the output is a matrix of quantiles, with each matrix row corresponding to the respective density.


Stefan Zeugner

See Also

quantile.default for a comparable function, pred.density and density.bma for the BMA-specific objects.

Check http://bms.zeugner.eu for additional help.


 mm = bms(datafls[1:70,], user.int=FALSE)
 #predict last two observations with preceding 70 obs:
 pmm = pred.density(mm, newdata=datafls[71:72,], plot=FALSE) 
 #'standard error' quantiles
 quantile(pmm, c(.05, .95))
 #Posterior density for Coefficient of "GDP60"
 cmm = density(mm, reg="GDP60", plot=FALSE) 
 quantile(cmm, probs=c(.05, .95))
 #application to generic density:
 dd1 = density(rnorm(1000))
## Not run: 
 #application to list of densities:
 quantile.density( list(density(rnorm(1000)), density(rnorm(1000))) )

## End(Not run)

[Package BMS version 0.3.5 Index]