| qineq | R Documentation |
carry out hypothesis tests and obtain associated confidence intervals for quantile based inequality measures
qineq(
x,
y = NULL,
J = 100,
measure = "QRI",
alternative = c("two.sided", "less", "greater"),
quantile.type = 7,
var.method = "qor",
conf.level = 0.95,
true.ineq = 0.5,
...
)
x |
a numeric vector of data values. |
y |
an optional second vector of data values for two-sample testing. |
J |
number of grid points |
measure |
character string of quantile based inequality measure to be estimated or a list of parameter choices or formula for user defined measures (see details for available measures and user defined measures). |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". |
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 help file for |
var.method |
approach use to estimate the quantile density function. Either "qor"(default) or "density".(See details). |
conf.level |
coverage for the estimated confidence interval. |
true.ineq |
the specified hypothesized value of the inequality measure or the difference of the inequality depending on whether it was a one-sample test or a two-sample test. |
... |
additional arguments to be passed to function |
This function performs hypothesis testing and calculates the corresponding confidence intervals for inequality measures based on quantiles.
Let l_1(p) and l_2(p) be functions of p \in [0,1] that defined linear combinations of quantiles. For example, if
x_{0.4} and x_{0.6} are the 0.4 and 0.6 quantiles respectively, and the ratio x_{0.4}/(x_{0.4} + x_{0.6}) is of
interest, then possible choices are l_1(p)=x_p and l_2(p)=x_p + x_{1-p} for p=0.4. The inequality measures supported
are of the form
I = 1 - \displaystyle\int^1_0\frac{l_1(p)}{l_2(p)}dp
and where I\in [0, 1].
Estimation of I is done numerically over a grid of points determined by integer J (default 100), where p_j = (j-1/2)/J,
and the estimate to I is
\widehat{I} = 1 - \frac{1}{J}\displaystyle\sum_{j=1}^J\frac{\hat{l}_1(p_j)}{\hat{l}_2(p_j)}
where \hat{l}_1(p_j) and \hat{l}_2(p_j) are the estimated linear combinations of quantiles at p_j.
The available options for quantile based measures in argument measure are shown below.
"QRI" : Quantile Ratio Index from Prendergast & Staudte (2018). This is the default choice.
"G1", "G2", "G3" : Quantile variants of the Gini index from Prendergast & Staudte (2016a).
"S1", "S2" : 'Strategy 1' and 'Strategy 2' income inequalities from Brazauskas et al. (2024).
The default var.method="qor" is to estimate the probability density function directly using the lognormal Quantile Optimality Ratio (QOR)
for choosing a suitable bandwidth (Prendergast & Staudte,2016b). Alternatively, the variances can be
estimated by inverting a density estimator evaluated at the quantiles and this can be done using var.method = "density". If var.method = "density",
then the function density is used to estimate the probability density function which is needed for the calculation of the covariance matrix using function qcov.
If needed, additional arguments can be passed to density (see ?density for details on possible additional arguments).
It is also possible for users to define their own inequality measures either using a formula or by creating a list. The formula approach is
the most straightforward of the two and can be defined in terms Q to specify a quantile function, p and then specifying the
formula which must be a ratio of linear combinations of quantiles, and where the coefficients may also contain p. As an example,
the QRI measure would be measure = ~ Q(p/2)/Q(1 - p/2) while G2 would require measure = ~ 2*Q(p/2)/Q(1 - p/2). More details
and examples can be found in Prendergast et al. (2024).
If measure is a list, it must be of the form list(u=...,coef1=...,coef2) where u is a numeric vector indicating the
probabilities for every quantile estimate needed for \hat{I}, coef1 and coef2 are numeric matrices with J rows
and number of columns equal to the length of u. Each row of coef1 stores the coefficients for the numerator
linear combination, and ditto coef2 for the denominator.
For more information and further examples, including user defined measures, see Prendergast, Dedduwakumara & Staudte (2024).
hypothesis test results and associated confidence interval (a list with class "htest")
Prendergast, L.A., & Staudte, R.G. (2016a). Quantile versions of the Lorenz curve. Electronic Journal of Statistics, 10(2), 1896 – 1926.
Prendergast, L. A., & Staudte, R. G. (2016b). Exploiting the quantile optimality ratio in finding confidence intervals for quantiles. Stat, 5(1), 70-81
Prendergast, L. A., & Staudte, R. G. (2018). A simple and effective inequality measure. The American Statistician, 72(4), 328-343.
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
Brazauskas, V., Greselin, F., & Zitikis, R. (2024). Measuring income inequality via percentile relativities. Quality & Quantity, 58(5), 4859-4896.
# Create some data
x <- c(8.43,7.08,8.79,8.88,7.87,5.94,8.79,5.46,8.11,7.08)
y <- c(13.44,13.65,14.77,9.51,14.07,10.92,11.59,13.42,8.93,10.88)
# Test of equality of QRI measure between two groups
qineq(x, y, measure = "QRI")
# Another way by defining the formula for the ratio in QRI
qineq(x, y, measure = ~ Q(p/2)/Q(1 - p/2))
# Another way by defining the quantiles and coefficients directly in a list
J <- 100
p <- (1:J - 0.5)/J
u <- sort(c(p/2, 1 - p/2))
num <- cbind(diag(rep(1, J)), matrix(0, J, J))
den <- cbind(matrix(0, J, J), diag(J)[, J:1])
qineq(x, y, measure = list(u = u, coef1 = num, coef2 = den))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.