Sunday, October 4, 2020

TI-84 Plus CE: Lorenz Curves and the Gini Coefficient

TI-84 Plus CE:  Lorenz Curves and the Gini Coefficient

Introduction - Graphing Income Inequality

Developed by Max O. Lornez, the Lorenz curve displays the graphs of income distribution and income inequality.  Each point of represents a cumulative percentage of an income level.   An example of a Lorenz curve:

(25%, 9%):   The first 25% of a population earns 9% of the population's total income

(50%, 21%):  Half of the population earns only 21% of the total income.

(75%, 44%):  The bottom 75% of the population earns 44% of the total income.

(100%, 100%):  This represents the total population.  

The Lornez curve is compared against a straight line which connects points (0%, 0%) to (100%, 100%).    The ratio between the top area and the whole curve is called a Gini coefficient.  If the Gini coefficient is 0, then there is no income inequality.  On the other hand, the closer that the Gini coefficient is to 1, there is more income inequality.  The diagram below is a Lorenz curve.



Calculating the Gini Coefficient


Let:

A = the area above the Lorenz  curve and below the straight line

B = the area above the x axis and below the Lorenz curve

W = the total area = A + B = 1/2 * max(x value) * max(y value)  

Note: that the total area is the area of a right triangle


The Gini coefficient is defined as:

G = A / (A + B) = (W - B) / B


TI-84 Plus CE Program: LORENZ

430 bytes


"2020-09-13 EWS"

Menu("LORENZ CURVE", "EQUAL PERCENTILE", 1, "DATA", 2)

Lbl 1

Input "DATA?", L4

dim(L4) → N

cumSum(L4) → L6

seq(100J/N, J, 1, N) → L3

L3 → L5

Goto 3

Lbl 2

Disp "ASCENDING ORDER: Y"

Input "X DATA?", L3

Input "Y DATA?", L4

cumSum(L3) / sum(L3) * 100 → L5

sumSum(L3 * L4) / sum(L3 * L4) * 100 → L6

Goto 3

Lbl 3

"BELOW"

augment( {0}, L5 ) → L5

augment( {0}, L6 ) → L6

sum( seq(.5 * (L5(J) - L5(J-1)) * (L6(J) + L6(J-1)) /2 , J, 2, dim(L6) ) ) → B

"WHOLE"

.5 * max(L5) * max(L6) → W

(W - B) / W → G

Disp "GINI INDEX:", G

Pause

Func

PlotsOff

FnOff

FnOn 1

PlotsOn 1

10 → Xscl : 10 → Yscl

Plot1( xyLine, L5, L6, □, RED)

"max(L6)*X/100" → Y1

ZoomStat


There are two options:

1. Equal Percentile:  Enter the percentage of each bin.  The percentile of each class is divided equally. Example:  for ten data points, the percentiles are split in 10% increments.

(10%, y1%)
(20%, y2%)
(30%, y3%)
(40%, y4%)
(50%, y5%)
(60%, y6%)
(70%, y7%)
(80%, y8%)
(90%, y9%)
(100%, y10%)

2.  Data:  Enter x and y data.   For y data, make sure that list has all of its elements in ascending order.

The graph displays in values of percents.  X Axis: 0 to 100 (representing 0% to 100%).  Y Axis: 0 to 100 (representing 0% to 100%).

Examples

Example 1:  Equal Percentile  

The total health spending for high average per capita in 10% percentiles in 2002.  (see source for background information)

Percentile Percent of Health Spending
10% 0%
20% 0.1%
30% 0.6%
40% 1.2%
50% 2%
60% 3.4%
70% 5.4%
80% 9.1%
90% 16.5%
100% 61.7%


Enter Option 1: Data.   

Gini Index: 0.8633

List = { 0, .1, .6, 1.2, 2, 3.4, 5.4, 9.1, 16.5, 61.7 }




Example 2:  Data

Hourly employees of a company and their wages:

Number of Employees Hourly Wage
156 $15.00
195 $30.00
53 $50.00
49 $70.00

X Data:  {156, 195, 53, 49}
Y Data:  {15, 30, 50, 70}

Gini Index:  0.6379627898



Source:

Reindhardt, Uwe E.   "The Construct of Lorenz Curves and of The Gini-Coeficient to Decpict Degrees in Inequality in Health Care"  Princeton University, WWS 597  (Political Economy of Health Systems) 
Retrieved August 26, 2020 


Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.