MyNixOS website logo
Description

Quantile-Based Inequality Indicators for Complex Survey Data.

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) <doi:10.1093/jssam/smaf024> for details.

inequantiles

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

Features

  • Quantile ratio index (QRI): estimation from survey data, parametric distributions, and grouped data
  • Traditional quantile-based inequality indicators: quantile-based share ratios (e.g., quintile share ratio and Palma index), percentile ratios (e.g., P90/P10)
  • Weighted quantile estimation: multiple interpolation rules (types 4–9 and Harrell-Davis) for complex survey data
  • Influence functions: linearization-based techniques for QRI, quantiles, quantile-based share ratios, percentile ratios and Gini
  • Grouped data: quantiles, QRI and Gini from frequency tables (e.g., fiscal/administrative data)
  • Variance estimation: rescaled bootstrap for complex sampling designs

Installation

# install.packages("devtools")
devtools::install_github("silviascarpa/inequantiles")

Quick Start

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")

Variance Estimation

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

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
       )

Grouped Data

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)

Citation

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

Getting Help

Metadata

Version

0.1.0

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows