Estimates quantile-based inequality indicators from complex
survey data, including the quantile ratio index (QRI), quintile share
Ratio (QSR), Palma ratio, and percentile ratios, together with the Gini
coefficient. Influence functions are provided for linearization and
variance estimation, along with a rescaled bootstrap for complex sampling
designs. Estimation from grouped data is also supported.
See Scarpa et al. (2025)
inequantiles is an R package for estimating quantile-based inequality indicators from survey microdata, with full support for complex sampling designs and weighted quantile estimation.
📖 Documentation and vignette: silviascarpa.github.io/inequantiles
# install.packages("devtools")
devtools::install_github("silviascarpa/inequantiles")
library(inequantiles)
data(synthouse)
# Weighted quantiles
csquantile(y = synthouse$eq_income,
weights = synthouse$weight,
probs = c(0.25, 0.5, 0.75),
type = 6)
# Quantile ratio index
qri(y = synthouse$eq_income,
weights = synthouse$weight)
# All indicators at once
inequantiles(y = synthouse$eq_income,
weights = synthouse$weight,
indicators = "all")
# Inequality curve
plot_inequality_curve(y = synthouse$eq_income,
weights = synthouse$weight,
main = "Inequality curve — synthouse")
Standard errors for all indicators can be estimated simultaneously via the rescaled bootstrap, using a single bootstrap loop for directly comparable results:
inequantiles(
y = synthouse$eq_income,
weights = synthouse$weight,
indicators = "all",
se = TRUE,
data = synthouse,
strata = "NUTS2",
psu = "municipality",
B = 200,
seed = 42
)
For custom estimators or more control over the bootstrap, use rescaled_bootstrap() directly.
Influence functions measure how much each observation affects an estimate — useful for analytical variance estimation and diagnosing influential observations.
# Influence function for the QRI
if_qri(y = synthouse$eq_income,
weights = synthouse$weight)
# Influence function for the QSR
if_share_ratio(y = synthouse$eq_income,
weights = synthouse$weight,
prob_numerator = 0.80, prob_denominator = 0.20)
# Influence function for the Gini coefficient
if_gini(y = synthouse$eq_income,
weights = synthouse$weight)
# Influence function for the median
if_quantile(y = synthouse$eq_income,
weights = synthouse$weight,
probs = 0.5)
# Influence function for P90/P10
if_ratio_quantiles(y = synthouse$eq_income,
weights = synthouse$weight,
prob_numerator = 0.90, prob_denominator = 0.10
)
When only frequency tables are available (e.g., tax records):
income_freq <- c(120, 180, 150, 80, 40, 20, 10)
income_tot <- c(18800, 16300, 44700, 33900, 21500, 22100, 98300)
income_lower <- c(0, 15000, 30000, 45000, 60000, 80000, 100000)
income_upper <- c(15000, 30000, 45000, 60000, 80000, 100000, 150000)
quantile_grouped(freq = income_freq,
lower_bounds = income_lower,
upper_bounds = income_upper,
probs = c(0.25, 0.5, 0.75))
qri_grouped(freq = income_freq,
lower_bounds = income_lower,
upper_bounds = income_upper)
gini_grouped(Y = income_tot, freq = income_freq)
If you use inequantiles in your research, please cite:
Scarpa, S. and Sperlich S. (2025). inequantiles: Quantile-Based Inequality Measures for Survey Data. R package. https://github.com/silviascarpa/inequantiles