qden: Quantile Density Estimation

View source: R/qden.R

qdenR Documentation

Quantile Density Estimation

Description

estimate the quantile density function using either a direct estimation approach with a bandwidth selected by the quantile optimality ratio (QOR), or by the density method which uses the inverse of the estimated density at the nominated quantiles

Usage

qden(
  x,
  u,
  dist = "gl",
  method = "qor",
  kernel = "epanechnikov",
  params = NULL,
  gl.control = list(method = "Lmom"),
  quantile.type = 8,
  bw.correct = TRUE,
  large.n.switch = TRUE,
  ...
)

Arguments

x

a numeric vector of data values.

u

a numeric vector of probability values in the interval (0,1) specifying where the quantile density is to be estimated. Missing values are not allowed.

dist

a character string naming a distribution or a quantile function name. Supported built-in distributions include "gl", "lnorm", "norm", and "exp".

method

the estimation method to use. The options are "qor" and "density".

kernel

the kernel to use when method = "qor".

params

a list of parameter values. If NULL, parameters are estimated where needed.

gl.control

a list of control arguments passed to fit.fkml when dist = "gl".

quantile.type

argument for the quantile function used when method = "density". Default is 8 so that output is consistent with other functions such as IQR.

bw.correct

logical; if TRUE, the bandwidth is corrected near the boundary.

large.n.switch

logical; if TRUE and dist = "gl" with large n, then "lnorm" is used for bandwidth selection.

...

additional arguments to be passed to density when method = "density" is used, or additional arguments passed to qor when method = "qor" is used.

Details

This function estimates the quantile density function at a vector of probability values u. Two estimation methods are available.

If method = "qor", a bandwidth is selected using the quantile optimality ratio (QOR) and a kernel-based estimator is used. The bandwidth depends on the selected kernel through its variance and roughness constants. Supported kernels are "epanechnikov", "gaussian", "rectangular", "triangular", "biweight", "cosine", and "optcosine". By default, the QOR method uses the flexible four parameter Generalized Lambda Distribution (GLD) to compute the QOR. The method of L-moments is used for GLD parameter estimation, although other estimators can be chosen by passing arguments through the gl.control argument to the fit.fkml function from the gld package which is used for estimation. Other included distributions for computing the QOR are the lognormal dist = "lnorm", Gaussian dist = "norm", and exponential "exp". If another character string is passed to dist, then the function will attempt to locate the associated quantile function and so dist needs to follow R's naming convention of prefixing the distribution name with q. E.g., dist = "beta" will use the associated quantile function for the beta distribution, qbeta. The parameter values to be used for this distribution can be specified using the list argument params. If params is NULL, the function will attempt to use default choices for these parameters.

If method = "density", the quantile density is estimated as the reciprocal of a density estimate evaluated at the estimated quantiles. When params is NULL, the density estimate is obtained directly from density. When params is supplied, the corresponding quantile and density functions from argument dist are used. E.g., if dist = "beta", then the quantile density will be computed using the qbeta and dbeta functions.

Value

a vector of estimated quantile density values at u.

References

Prendergast, L. A., Dedduwakumara, D.S. & Staudte, R.G. (2024). rquest: An R package for hypothesis tests and confidence intervals for quantiles and summary measures based on quantiles. Preprint, pages 1–13.

See Also

qor for quantile optimality ratio values, qcov for covariance estimation of sample quantiles, and qrcov for covariance estimation of ratios of linear combinations of quantiles.

Examples

set.seed(1234)
x <- rnorm(100)

# QOR-based quantile density estimation using the flexible GLD distribution (default method)
qden(x, c(0.25, 0.5, 0.75), method = "qor")

# QOR-based quantile density estimation using the normal distribution
qden(x, c(0.25, 0.5, 0.75), dist = "norm", method = "qor")

# Density-based quantile density estimation
qden(x, c(0.25, 0.5, 0.75), method = "density")

rquest documentation built on Aug. 28, 2026, 9:06 a.m.