qcov: Approximate Covariance Matrix Estimation for Vectors of...

View source: R/qcov.R

qcovR Documentation

Approximate Covariance Matrix Estimation for Vectors of Quantile Estimators

Description

compute a covariance matrix consisting of variances (on the diagonal) for quantile estimates and covariances (off-diagonal) between different quantile estimates

Usage

qcov(
  x,
  u,
  method = "qor",
  dist = "gl",
  quantile.type = 7,
  bw.correct = TRUE,
  params = NULL,
  ...
)

Arguments

x

a numeric vector of data values.

u

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

method

the approach used to estimate the quantile density function. Either "qor" or "density".

dist

a character string naming a supported distribution or a quantile function name used by qden.

quantile.type

argument for the quantile function. Default is set to 7 so that output is consistent with default quantile function use and other functions such as IQR (see ?quantile for details).

bw.correct

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

params

a list of parameter values for the chosen distribution. If NULL, parameters are estimated where needed.

...

additional arguments to be passed to qden when method = "qor" and to density when method = "density".

Details

This function computes an approximate covariance matrix for a vector of sample quantile estimators. The covariance structure is based on the asymptotic relationship, for u_i\leq u_j and sample size n,

\mathrm{Cov}(\widehat Q(u_i), \widehat Q(u_j)) \approx \displaystyle\frac{u_i(1 - u_j)}{n}\, q(u_i)\, q(u_j),

where q(u)=Q'(u) is the quantile density.

The quantile density is estimated by qden. By default, method = "qor" is used, which estimates the quantile density using the quantile optimality ratio (QOR) approach of Prendergast and Staudte (2016). Alternatively, method = "density" estimates the quantile density by fitting a density function and taking its reciprocal at the estimated quantiles.

The argument dist specifies the working distribution used by qden. It may be one of the built-in distributions supported by qden, or a quantile function name when a user-supplied distribution is to be used. If params is NULL, the required distributional parameters are estimated from the data where appropriate.

If method = "qor", the bandwidth is selected using the QOR approach. The argument bw.correct controls the boundary correction used in that bandwidth calculation.

If method = "density", additional arguments in ... are passed to density when density estimation is used directly.

Value

a covariance matrix consisting of variances (on the diagonal) for quantile estimates and covariances (off-diagonal) between different quantile estimates.

References

Prendergast, L. A., & Staudte, R. G. (2016). Exploiting the quantile optimality ratio in finding confidence intervals for quantiles. Stat, 5(1), 70–81.

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

qden for estimating the quantile density function, qor for quantile optimality ratio values, and qrcov for covariance matrices of ratios of linear combinations of quantiles.

Examples

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

# Covariance matrix for sample quartiles
qcov(x, c(0.25, 0.5, 0.75))

# Density-based version
qcov(x, c(0.25, 0.5, 0.75), method = "density")

rquest documentation built on Nov. 23, 2026, 9:08 a.m.