qrcov: Approximate Covariance Matrix Estimation for Ratios of Linear...

View source: R/qrcov.R

qrcovR Documentation

Approximate Covariance Matrix Estimation for Ratios of Linear Combinations of Quantile Estimators

Description

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

Usage

qrcov(x, u, coef1, coef2, quantile.type = 8, ...)

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. Note that u must include numeric values between, and not including, 0 and 1 and missing values are not allowed.

coef1

a numeric matrix whose ith row contains the coefficients for the numerator linear combination for the ith ratio.

coef2

a numeric matrix whose ith row contains the coefficients for the denominator linear combination for the ith ratio.

quantile.type

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

...

additional arguments to be passed to function density when method = “density” is used.

Details

This function computes a sample covariance matrix for ratios of linear combinations of quantile estimates from a single sample. This is done via a sample covariance matrix for the quantiles used in the linear combinations which is obtained using function qcov. Let \mathbf{q} denote a vector of quantile estimators, \mathbf{S} denote the covariance matrix for \mathbf{q}, and \mathbf{c}_{1i} and \mathbf{c}_{2i} i=1,\ldots,r be the numerator and denominator vectors of coefficients that define the linear combinations used in each of the r ratios (e.g. the ith ratio is R_i = (\mathbf{c}_{1i}^\top \mathbf{q})/(\mathbf{c}_{2i}^\top \mathbf{q})). Then, using the Delta method, an approximate covariance matrix for [R_1,\ldots,R_r]^\top is

\mathbf{J}\mathbf{S}\mathbf{J}^\top

where \mathbf{J} is the Jacobian matrix whose ith row is the gradient vector of R_i.

Value

a list consisting of ratios (the ratio estimates) and cov (the estimated covariance matrix).

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

Examples

# Create some data
set.seed(1234)
x <- rnorm(100)

# Compute the variance-covariance matrix for the ratio of third
# quartile and the median and the ratio of first quartile and the median.
coef1 <- matrix(c(0, 0, 1, 1, 0, 0), nrow = 2, byrow = TRUE)
coef2 <- matrix(c(0, 1, 0, 0, 1, 0), nrow = 2, byrow = TRUE)
qrcov(x, c(0.25, 0.5, 0.75), coef1 = coef1, coef2 = coef2)

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