Computes one or more quantile-based inequality indicators simultaneously among QRI, QSR, Palma ratio, and percentile ratio, optionally with standard errors (estimated from the same set of bootstrap replicates), ensuring full comparability across indicators.
Usage
inequantiles(
y,
weights = NULL,
indicators = "all",
se = FALSE,
type = 6,
na.rm = TRUE,
M = 100,
prob_num = 0.9,
prob_den = 0.1,
B = 200,
seed = NULL,
data = NULL,
strata = NULL,
psu = NULL,
N_h = NULL,
m_h = NULL,
verbose = TRUE
)Arguments
- y
A numeric vector of strictly positive values (e.g. income, wealth, expenditure).
- weights
A numeric vector of sampling weights. If
NULL, all observations are equally weighted.- indicators
Character vector specifying which indicators to compute. Use
"all"(default) for all four, or any subset of"qri","qsr","palma","ratio_quantiles".- se
Logical; if
TRUE, bootstrap standard errors are computed.- type
Quantile estimation type (integer 4–9 or
"HD"for Harrell-Davis). Default:6. Seecsquantile.- na.rm
Logical; remove missing values before computing? Default:
TRUE.- M
Integer; number of quantile-ratio grid points for the QRI (default:
100). Only used when the QRI is estimated; seeqri.- prob_num
Numeric in \((0,1)\); numerator quantile for the percentile ratio (default:
0.90). Only used when percentiles ratio is estimated; seeratio_quantiles.- prob_den
Numeric in \((0,1)\); denominator quantile for the percentile ratio (default:
0.10). Only used when percentiles ratio is estimated; seeratio_quantiles.- B
Integer; number of bootstrap replicates (default:
200). Only used whense = TRUE.- seed
Integer; random seed for reproducibility. Only used when
se = TRUE.- data
A data frame containing the survey design variables (strata, PSU). Required when
se = TRUE.- strata
Character string; name of the stratification column in
data. Required whense = TRUE.- psu
Character string; name of the PSU column in
data. Required for two-stage complex designs.- N_h
Optional named numeric vector of stratum population sizes for the finite population correction. See
rescaled_bootstrap.- m_h
Optional vector of bootstrap sample sizes per stratum. Defaults to the Rao-Wu formula. See
rescaled_bootstrap.- verbose
Logical; if
TRUE(default), displays a progress bar during bootstrap iterations.
Value
A list with components:
- estimates
Numeric vector of point estimates of inequality indicators.
- se
Numeric vector of standard errors, or
NULLwhense = FALSE.- B
Number of bootstrap replicates used, or
NULL.- call
The matched function call.
Details
All indicators are computed from the same specified csquantile type.
When se = TRUE, a single bootstrap loop is run through rescaled
bootstrap method (see details in rescaled_bootstrap) and all
indicators are evaluated on each replicate, so standard errors are based on
identical resamples and are directly comparable.
See also
qri, qsr, palma_ratio,
ratio_quantiles, rescaled_bootstrap
Other inequality indicators based on quantiles:
palma_ratio(),
plot_inequality_curve(),
qri(),
qsr(),
ratio_quantiles()
Examples
data(synthouse)
eq <- synthouse$eq_income
w <- synthouse$weight
# Point estimates only
inequantiles(eq, weights = w)
#> Quantile-based inequality indicators
#> -------------------------------------
#> Estimate
#> qri 0.5691
#> qsr 7.0161
#> palma 1.5787
#> p90p10 5.9206
# Subset of indicators
inequantiles(eq, weights = w, indicators = c("qri", "palma"))
#> Quantile-based inequality indicators
#> -------------------------------------
#> Estimate
#> qri 0.5691
#> palma 1.5787
# Custom percentile ratio (P80/P20 instead of P90/P10)
inequantiles(eq, weights = w, indicators = "ratio_quantiles",
prob_num = 0.80, prob_den = 0.20)
#> Quantile-based inequality indicators
#> -------------------------------------
#> Estimate
#> p80p20 3.2411
# \donttest{
# With bootstrap standard errors (complex design)
inequantiles(eq, weights = w,
se = TRUE, B = 50, seed = 42,
data = synthouse, strata = "NUTS2",
psu = "municipality",
verbose = FALSE)
#> Quantile-based inequality indicators
#> -------------------------------------
#> Estimate SE
#> qri 0.5691 0.0046
#> qsr 7.0161 0.1757
#> palma 1.5787 0.0387
#> p90p10 5.9206 0.1638
#>
#> Bootstrap replicates: 50
# }