In contrast to our previous post, that is the post that summarized the Lorenz Curve in general terms, this post details how to construct the Lorenz Curve and provides a hypothetical example in R.

Generally, one can compute the Lorenz Curve according to the following steps:

1. Prepare your income or wealth data (in this example we use six fictional monthly income figures)

2.200, 1.200, 4.100, 1.500, 3.500, 1.000

2. Arrange your income or wealth data in an ascending way.

1.000, 1.200, 1.500, 2.200, 3.500, 4.100

3. Compute the cummulative sum of the ordered data

1000, 2.200, 3.700, 5.900, 9.400, 13.500

4. Divide the cummulative sum by the total income or wealth

1000, 2.200, 3.700, 5.900, 9.400, 13.500 / devide by 13.500

5. Finally, you obtain the single values for the Lorenz Curve

0.074, 0.163, 0.274, 0.437, 0.696, 1

One can interpret the values of the Lorenz Curve the following way: 33% of the population earn 16.3% of total income. The richest 33% earn 56.3% of total income.

The following R code simulates the Lorenz Curves that are used in this post. It simulates three economies with different degrees of inequality.

# start with empty workspace rm(list=ls()) # function to compute the Lorenz curve lorenz_curve <- function(x){ cumsum(x)/max(cumsum(x)) } # simulate different Lorenz curves population <- 100 wealth_equal <- rep(1,population) wealth_unequal <- (1:population)^1.2 wealth_very_unequal <- (1:population)^5 lorenz_curve_equal <- lorenz_curve(wealth_equal) lorenz_curve_unequal <- lorenz_curve(wealth_unequal) lorenz_curve_very_unequal <- lorenz_curve(wealth_very_unequal) # plot Lorzenz curve png("lorenz_curve.png", height=960,width=960) par(mar=c(6.1,5.1,4.1,2.1)) plot(lorenz_curve_equal,type="l",main="Lorenz Curve", ylab="Cumulative share of income earned", xlab="Cumulative share of people from lowest to highest incomes", col="green",cex.main=3,cex.lab=2,cex.axis=2,lwd=3) lines(lorenz_curve_unequal,col="orange",lwd=3) lines(lorenz_curve_very_unequal,col="red",lwd=3) text(50,0.55,"Equal Wealth",srt=40,cex = 2) text(60,0.40,"Unequal Wealth",srt=45,cex = 2) text(70,0.20,"Very Unequal Wealth",srt=45,cex = 2) dev.off() png("lorenz_curve2.png", height=960,width=960) par(mar=c(6.1,5.1,4.1,2.1)) plot(lorenz_curve_equal,type="l",main="Lorenz Curve", ylab="Cumulative share of income earned", xlab="Cumulative share of people from lowest to highest incomes", col="green",cex.main=3,cex.lab=2,cex.axis=2,lwd=3) lines(lorenz_curve_unequal,col="orange",lwd=3) lines(lorenz_curve_very_unequal,col="red",lwd=3) segments(60, 0, x1 = 60, y1 = 0.6,lty = 2) segments(0, 0.60, x1 = 60, y1 = 0.60,lty = 2) segments(0, 0.33, x1 = 60, y1 = 0.33,lty = 2) segments(0, 0.05, x1 = 60, y1 = 0.05,lty = 2) text(52,0.65,"60%",cex = 2) text(52,0.38,"33%",cex = 2) text(52,0.1,"5%",cex = 2) dev.off()