View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Inequality Package

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

5.0
5.0 | 1 rating Rate this file 14 Downloads (last 30 days) File Size: 7.76 KB File ID: #19968 Version: 1.3
image thumbnail

Inequality Package

by

 

18 May 2008 (Updated )

Inequality Metrics: Gini Coefficient associated to the Lorenz Curve, Theil and Atkinson indexes

| Watch this File

File Information
Description

Package on Inequality Metrics: the Gini Coefficient associated to the Lorenz Curve, the Theil and the Atkinson indexes.
For more references:
http://en.wikipedia.org/wiki/Lorenz_curve
http://en.wikipedia.org/wiki/Gini_coefficient
http://en.wikipedia.org/wiki/Theil_index
http://en.wikipedia.org/wiki/Atkinson_index

***************************

Note that contributions #15376 and #28080 DO NOT return the correct Gini coefficient, while #26452 does not apply to populations but only to individuals.

***************************

The zip file contains:
ginicoeff.m
lorenzcurve.m
theilt.m
theill.m
atkinsonineq.m

***************************

% Example for ginicoeff.m:
N = 1000;
p = rand(N, 1); w = rand(N, 1);
y = ginicoeff(p, w)

% ***************************

% Example for lorenzcurve.m:
N = 1000;
p = rand(N, 1);
w = exp(randn(N, 1));
h = lorenzcurve(p, w);

% ***************************

% Example for theilt.m:
N = 1000;
w = rand(N, 1);
y = theilt(w)

% ***************************

% Example for theill.m:
N = 1000;
w = rand(N, 1);
y = theill(w)

% ***************************

% Example for atkinsonineq.m:
N = 1000;
w = rand(N, 1);
epsilon = rand;
y = atkinsonineq(w, epsilon)

Acknowledgements

Gini Coefficient Population Weighted inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7 (R14)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
22 Mar 2016 B

B (view profile)

Got it thanks for the clarification, I didn't realize yours used the total size of the population.

Comment only
14 Mar 2016 Liber Eleutherios

Hi B, thank you for your question about a point that is often misunderstood. Let us try to clarify this point once and for all.

In my function, FEX 19968, ginicoeff requires two variables: p and w, respectively the size of the population and the TOTAL value associated with that population (for example population and TOTAL GDP).

In the function FEX 28080, gini requires two variables: pop and val, respectively the size of the population and the AVERAGE value associated with that population (for example population and PER-CAPITA GDP).

Let

p = (1:100)'; % Population
w = (1:100)'; % Total GDP
g1 = ginicoeff(p, w)

FEX 19968 will return zero because 1 individual has a total value of 1, two individuals have a total value of 2, etc., and 100 individuals have a total value of 100. On average everyone has a value of 1, therefore this is the case of maximum dispersion, i.e. minimum inequality.

FEX 28080 will also return zero, IF you divide w by p:

g2 = gini(p, w ./ p)

I hope this helps.

Comment only
14 Mar 2016 B

B (view profile)

I downloaded this package for the lorenze curve plotting. However I was calculating the gini using this function and comparing it to an old calculation I had and to another package on FileExchange (http://www.mathworks.com/matlabcentral/fileexchange/28080-gini-coefficient-and-the-lorentz-curve) it seemed to differ. Has anyone else noticed the gini disagreeing with their own calculations? Maybe this gini requires a different format or something, but I didn't seem to notice a difference. The gini from the package was coming out higher than expected. Cheers

Comment only
06 Jun 2012 Liber Eleutherios

@Martin, thank you for your comment but check it again: the Gini coefficient of your example IS NOT zero but some random number.

@Robert, thank you for your comment - I would use random data or the GDP and Population of a selection of countries.

Comment only
16 May 2012 Robert Root

Excited to find this package. I'd like to use it in my courses. Where can I find actual data in the format this package accepts?

Comment only
30 Aug 2011 martin

martin (view profile)

I want ask a question, why I set p=rand(100,1); w=p, and the GiniCoeff(p,w) is not o. Theoratically, the answer should be zero!

Comment only
30 Aug 2011 martin

martin (view profile)

very good, Thank you!

Updates
08 Feb 2009 1.1

I have made two major corrections to the functions GiniCoeff and plotLorenzCurve

18 Sep 2012 1.2

All functions have been entirely re-written.

12 Jan 2015 1.3

minor edits

Contact us