liveBook · Manning

Lc() function

As explained in Statistics Slam Dunk

The Lc() function from the ineq package computes Lorenz-curve statistics for a numeric distribution.

Lc() from the ineq package computes Lorenz-curve statistics for a numeric distribution. Pair it with base R's plot() to visualize inequality in data such as NBA player win shares. section 13.6.2

A practical workflow prepares the distribution before plotting:

  • Filter the desired years, reshape win shares into one column per year, remove identifiers, and convert the result to a data frame. section 13.6.2
  • Loop across the four year columns, pass each numeric vector to Lc(), and create a titled Lorenz-curve plot. section 13.6.2

Plot four years of win-share inequality

With the prepared ws9194 data frame, par(mfrow = c(2, 2)) arranges four panels. The loop assigns each column to x and plots Lc(x), producing Lorenz curves for 1991 through 1994. section 13.6.2

par(mfrow = c(2, 2)) 

loop.vector <- 1:4

for (i in loop.vector) {
x <- ws9194[,i]

plot(Lc(x), col = "red", lwd = 2,
     main = paste0("Lorenz Curve\n", "199", i),
     xlab = "Win Share Distribution",
     ylab = "Percentage of NBA Players")
}

Inspect the executable loop that applies Lc() to each year and labels the resulting plots. section 13.6.2

How Statistics Slam Dunk covers it

How deep it goes
Demonstrates function use through data preparation and plotting, but does not derive the Lorenz-curve calculation internally.
Examples
Uses NBA win-share columns from 1991 through 1994 to generate four consolidated Lorenz-curve panels.
What it assumes
Assumes a prepared numeric distribution and basic familiarity with R data frames, loops, and plot().
What you can do after
Apply it via R to generate Lorenz curves for several numeric distributions with concise loop-based code.
How it connects
Connects Lorenz curves with Gini coefficients, for loops, base R plotting, and numeric distributions.

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.