liveBook · Manning

Ineq

As explained in Statistics Slam Dunk

ineq is an R package that provides statistical measures and methods for analyzing income and other distributions of inequality.

ineq is an R package for measuring distributional inequality. Its ineq() function accepts a numeric vector and returns a Gini coefficient, while Lc() supports Lorenz-curve analysis. section 12.2 section 13.6.2

Use ineq to:

  • Compute Gini coefficients for individual distributions or grouped observations such as annual salaries and win shares. section 12.5 section 13.4
  • Interpret coefficients from 0, representing perfect equality, toward 1, representing perfect inequality. section 13.4
  • Pair Gini summaries with ggplot2 line charts to compare inequality across seasons. section 12.5 section 13.4
  • Generate multiple Lorenz curves by passing prepared vectors to Lc() inside a base R loop. section 13.6.2

Comparing simple income distributions

a <- rep(50, each = 10) ineq(a) ## [1] 0 f <- rep(c(10, 100), times = c(9, 1)) ineq(f) ## [1] 0.4263158 Equal incomes produce a Gini coefficient of 0; concentrating income in one person raises it to about 0.43. Scaling every income upward does not necessarily change the coefficient. section 12.5

library(tidyverse)
library(sqldf)
library(ineq)
library(gglorenz)
library(scales)
library(effsize)

Load ineq before calling its functions; install it first when necessary. section 12.2

How Statistics Slam Dunk covers it

How deep it goes
Explains vector-based Gini calculation, grouped summaries, and Lorenz-curve plotting without detailing package internals.
Examples
Demonstrates equal and concentrated incomes, NBA salary and win-share summaries, seasonal charts, and four Lorenz curves.
What it assumes
Assumes basic R vectors and data manipulation while demonstrating package installation, importing, grouping, reshaping, and looping.
What you can do after
Apply it via R to calculate Gini coefficients, summarize them by group, and plot inequality trends or Lorenz curves.
How it connects
Connects Gini coefficients with Lorenz curves, dplyr grouping, base R loops, and ggplot2 visualization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.