A technical working paper for this package can be found here.
Measure income and wealth inequality in R. Gini coefficients with confidence intervals, Theil indices, Atkinson indices, Palma ratios, Lorenz curves, poverty measures, tax progressivity, and more. All functions accept optional survey weights, and every measure now exposes bootstrap confidence intervals via ci = TRUE.
This release responds to feedback from Frank Cowell and Emmanuel Flachaire on the v0.1.0 release.
iq_theil, iq_atkinson, iq_sgini, iq_palma, iq_hoover, iq_kolm, iq_percentile_ratio, iq_polarisation, iq_shares, iq_concentration, iq_kakwani, and iq_poverty all gain ci, R, and level arguments. iq_compare() runs a single bootstrap loop and propagates CIs to every row.iq_compare() accept negatives = "keep" for distributions containing negatives (wealth, post-tax income).iq_gini(x, negatives = "keep", normalised = TRUE) rescales the index back into [0, 1] when negatives are present.iq_concentration alongside the existing Erreygers correction.iq_kakwani bug fix. The post-tax Gini no longer takes the absolute value of negative net incomes, so the Reynolds-Smolensky index is honest under high tax burdens.# install.packages("devtools")
# devtools::install_github("charlescoverdale/inequality")
install.packages("inequality", repos = c('https://charlescoverdale.r-universe.dev', 'https://cloud.r-project.org'))
The main CRAN package for inequality measurement (ineq) was last updated in 2014. It computes basic Gini and Theil indices but has no support for survey weights, no confidence intervals, no subgroup decomposition, no poverty measures, no Palma ratio, and no tax progressivity analysis.
inequality fills these gaps. You bring income or wealth data from any source (household surveys, tax records, administrative data, simulations) and the package handles measurement, decomposition, and comparison. Every function accepts optional weights, returns a clean S3 object with a print method, and cites the underlying academic paper.
library(inequality)
# Built-in sample data: 1000 synthetic incomes
d <- iq_sample_data("income")
# How unequal is this distribution?
iq_gini(d$income)
#> -- Gini Coefficient --
#> * Gini: 0.43
#> * Observations: 1000
# With confidence intervals
iq_gini(d$income, ci = TRUE)
#> -- Gini Coefficient --
#> * Gini: 0.43
#> * Observations: 1000
#> * Bootstrap 95% CI: [0.4085, 0.453]
iq_compare(d$income)
#> -- Inequality Comparison (n = 1000) --
#> * Gini 0.4300
#> * Theil T (GE1) 0.3307
#> * Theil L (GE0) 0.3241
#> * Atkinson (e=0.5) 0.1506
#> * Atkinson (e=1.0) 0.2768
#> * Palma ratio 2.1668
#> * Hoover 0.3126
#> * P90/P10 7.83
#> * P80/P20 3.92
iq_shares(d$income)
#> -- Income Shares --
#> * Bottom 50%: 21.2% of income (50% of population)
#> * P50-P90: 47.1% of income (40% of population)
#> * P90-P99: 24.0% of income (9% of population)
#> * Top 1%: 6.6% of income (1% of population)
d <- iq_sample_data("grouped")
iq_decompose(d$income, d$group)
#> -- Between-Within Decomposition (Theil T (GE(1))) --
#> * Total: 0.463
#> * Between: 0.116 (25.1%)
#> * Within: 0.347 (74.9%)
d <- iq_sample_data("income")
iq_poverty(d$income, line = 20000)
#> -- Poverty Measures (line = 20000) --
#> * Headcount (FGT0): 18.2%
#> * Poverty gap (FGT1): 0.0521
#> * Severity (FGT2): 0.0198
#> * Sen index: 0.0912
#> * Watts index: 0.0634
pre_tax <- d$income
tax <- pre_tax * (0.10 + 0.15 * (pre_tax / max(pre_tax)))
iq_kakwani(pre_tax, tax)
#> -- Fiscal Progressivity (Progressive) --
#> * Kakwani index: 0.1832
#> * Reynolds-Smolensky index: 0.0421
# Lorenz curve
lc <- iq_lorenz(d$income)
plot(lc)
# Growth incidence curve
panel <- iq_sample_data("panel")
gic <- iq_growth_incidence(panel$income_t0, panel$income_t1)
plot(gic)
| Function | What it measures |
|---|---|
iq_gini() |
Gini coefficient (bootstrap or asymptotic CIs) |
iq_sgini() |
Extended Gini family (adjustable inequality aversion) |
iq_theil() |
Theil T, Theil L, and generalised entropy GE(alpha) |
iq_atkinson() |
Atkinson index (with equally distributed equivalent income) |
iq_kolm() |
Kolm index (absolute inequality, translation invariant) |
iq_palma() |
Palma ratio (top 10% share / bottom 40% share) |
iq_hoover() |
Hoover index (Robin Hood index, Pietra index) |
iq_percentile_ratio() |
P90/P10, P80/P20, or custom ratios |
| Function | What it measures |
|---|---|
iq_lorenz() |
Lorenz curve with plot method |
iq_shares() |
Income shares by quantile (top 1%, top 10%, etc.) |
iq_decompose() |
Between-within group decomposition (GE family) |
iq_concentration() |
Concentration index with optional Erreygers correction |
iq_polarisation() |
Wolfson bipolarisation index |
| Function | What it measures |
|---|---|
iq_poverty() |
FGT family (headcount, gap, severity), Sen and Watts indices |
iq_growth_incidence() |
Growth incidence curve (is growth pro-poor?) |
| Function | What it measures |
|---|---|
iq_kakwani() |
Kakwani progressivity + Reynolds-Smolensky redistribution |
| Function | What it does |
|---|---|
iq_compare() |
All major indices in one table |
iq_sample_data() |
Built-in synthetic data for examples |
| Source | Coverage | R package |
|---|---|---|
| World Bank PIP | Global poverty and inequality | pipr |
| World Inequality Database | Top income shares, 100+ countries | wid |
| Luxembourg Income Study | Harmonised household surveys | lissyrtools |
| OECD Income Distribution | OECD member Gini, P90/P10, shares | readoecd |
| Eurostat EU-SILC | European household income | eurostat |
| UK Family Resources Survey | UK income distribution | Download CSV |
| US Current Population Survey | US income and poverty | ipumsr |
| UN WIDER WIID | Cross-country inequality database | Download CSV |
| Package | Description |
|---|---|
| hmrc | UK income tax data (Income Tax by income range) |
| ato | Australian Taxation Office (income distributions) |
| ons | UK Office for National Statistics data (household income, ASHE) |
| ukhousing | UK Land Registry, EPC, and planning data (housing wealth) |
| ivcheck | IV diagnostics (for distributional treatment effects) |
| inflationkit | Inflation analysis (real-terms incomes) |
Report bugs or request features at GitHub Issues.
inequality, Gini, Theil, Atkinson, Kolm, Lorenz, Palma, Kakwani, poverty, FGT, decomposition, income distribution, wealth, survey weights, economics, progressivity