Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schutz inequality measures #75

Merged
merged 23 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7108b22
ENH: Atkinson inequality index
sjsrey Jul 23, 2024
00ad438
ENH: Schutz index and plot
sjsrey Jul 24, 2024
cb7fee0
ENH: options for labels and grid in schutz plot
sjsrey Jul 24, 2024
d70b5c0
Merge branch 'main' of github.com:pysal/inequality into atkinson
sjsrey Aug 20, 2024
5a99061
ENH: Atkinson measures and reference
sjsrey Aug 20, 2024
5bb649a
Merge branch 'main' of github.com:pysal/inequality into schutz
sjsrey Aug 21, 2024
e11d797
ENH: Schutz inequality measures
sjsrey Aug 21, 2024
e174823
Correct docstring format
sjsrey Aug 21, 2024
234f4e1
Fix docstring
sjsrey Aug 21, 2024
cbabad6
Merge branch 'atkinson' into schutz
sjsrey Aug 21, 2024
4f33d37
Ruff
sjsrey Aug 21, 2024
daea79e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2024
bb31d79
Update tests
sjsrey Aug 21, 2024
6fec593
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2024
56a51a6
REF: make atkinson function public
sjsrey Aug 22, 2024
927dad5
adjust tests for public atkinson
sjsrey Aug 22, 2024
aa59a15
Merge branch 'schutz' of github.com:sjsrey/inequality into schutz
sjsrey Aug 22, 2024
9011aee
REF public atkinson
sjsrey Aug 22, 2024
3eb67f2
Update inequality/schutz.py
sjsrey Aug 22, 2024
f031729
Update inequality/schutz.py
sjsrey Aug 22, 2024
ddd245d
TEST: refactor for testing on windows/ci
sjsrey Sep 1, 2024
0277fb6
Merge branch 'schutz' of github.com:sjsrey/inequality into schutz
sjsrey Sep 1, 2024
b7a0947
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/_static/references.bib
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
@article{schutz1951MeasurementIncome,
title = {On the {{Measurement}} of {{Income Inequality}}},
author = {Schutz, Robert R.},
year = {1951},
journal = {The American Economic Review},
volume = {41},
number = {1},
eprint = {1815968},
eprinttype = {jstor},
pages = {107--122},
publisher = {American Economic Association},
issn = {0002-8282},
urldate = {2024-07-22},
file = {/home/serge/Zotero/storage/B54Q8IH7/Schutz - 1951 - On the Measurement of Income Inequality.pdf}
}


@Article{Atkinson_1970_Measurement,
title = {On the Measurement of Inequality},
author = {Atkinson, Anthony B},
year = {1970},
journal = {Journal of Economic Theory},
volume = {2},
number = {3},
pages = {244--263},
issn = {00220531},
doi = {10.1016/0022-0531(70)90039-6},
urldate = {2024-08-09},
}

@article{care_2012,
author = {Care, David C. and Pinkerton, Ruth M. and Poot, Jacques and Coleman, Andrew},
title = {{Residential sorting across Auckland neighbourhoods}},
Expand Down
32 changes: 25 additions & 7 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ API reference

.. _inequality_api:

Theil Inequality Measures
-------------------------

Atkinson Inequality Measures
----------------------------

.. autosummary::
:toctree: generated/

inequality.theil.Theil
inequality.theil.TheilD
inequality.theil.TheilDSim


inequality.atkinson.Atkinson

Gini Inequality Measures
------------------------

Expand All @@ -27,6 +25,26 @@ Gini Inequality Measures
inequality.gini.Gini
inequality.gini.Gini_Spatial

Schutz Inequality Measures
--------------------------

.. autosummary::
:toctree: generated/

inequality.schutz.Schutz


Theil Inequality Measures
-------------------------

.. autosummary::
:toctree: generated/

inequality.theil.Theil
inequality.theil.TheilD
inequality.theil.TheilDSim


Pengram
-------

Expand Down
2 changes: 1 addition & 1 deletion inequality/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import contextlib
from importlib.metadata import PackageNotFoundError, version

from . import gini, theil
from . import atkinson, gini, schutz, theil
from ._indices import (
abundance,
ellison_glaeser_egg,
Expand Down
112 changes: 112 additions & 0 deletions inequality/atkinson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import numpy as np

__all__ = ["Atkinson", "atkinson"]


def atkinson(y, epsilon):
"""Compute the Atkinson index for a given distribution of income or wealth.

The Atkinson index is a measure of economic inequality that takes
into account the social aversion to inequality. It is sensitive to
changes in different parts of the income distribution depending on
the value of the parameter epsilon.

Parameters
----------
y : array-like
An array of income or wealth values.
epsilon : float
The inequality aversion parameter. Higher values of epsilon
give more weight to the lower end of the distribution, making
the index more sensitive to changes in the lower tail.

Returns
-------
float
The Atkinson index, which ranges from 0 (perfect equality) to
1 (maximum inequality).

Notes
-----
- If epsilon equals 0, the Atkinson index is 0 regardless of the
distribution, as it implies no aversion to inequality.
- If epsilon equals 1, the Atkinson index is calculated using the
geometric mean.
- The input array y should contain positive values for a
meaningful calculation.

Example
-------
>>> import numpy as np
>>> incomes = np.array([10, 20, 30, 40, 50])
>>> float(round(atkinson(incomes, 0.5), 5))
0.06315
>>> float(round(atkinson(incomes, 1),5))
0.13161

"""
y = np.asarray(y)
if epsilon == 1:
geom_mean = np.exp(np.mean(np.log(y)))
return 1 - geom_mean / y.mean()
else:
ye = y ** (1 - epsilon)
ye_bar = ye.mean()
ye_bar = ye_bar ** (1 / (1 - epsilon))
return 1 - ye_bar / y.mean()


class Atkinson:
"""A class to calculate and store the Atkinson index and the equally
distributed equivalent(EDE).

The Atkinson index is a measure of economic inequality that takes
into account the social aversion to inequality. The equally
distributed equivalent (EDE) represents the level of income that,
if equally distributed, would give the same level of social
welfare as the actual distribution.

See: cite: `Atkinson_1970_Measurement`.

Parameters
----------
y: array-like
An array of income or wealth values.
epsilon: float
The inequality aversion parameter. Higher values of epsilon
give more weight to the lower end of the distribution, making
the index more sensitive to changes in the lower tail.

Attributes
----------
y: array-like
The input array of income or wealth values.
epsilon: float
The inequality aversion parameter.
A: float
The calculated Atkinson index.
EDE: float
The equally distributed equivalent(EDE) of the income or
wealth distribution.

Example
-------
>> > incomes = np.array([10, 20, 30, 40, 50])
>> > atkinson = Atkinson(incomes, 0.5)
>> > float(round(atkinson.A, 5))
0.06315
>> > float(round(atkinson.EDE, 5))
28.1054
>> > atkinson = Atkinson(incomes, 1)
>> > float(round(atkinson.A, 5))
0.13161
>> > float(round(atkinson.EDE, 5))
26.05171

"""

def __init__(self, y, epsilon):
self.y = np.asarray(y)
self.epsilon = epsilon
self.A = atkinson(y, epsilon)
self.EDE = y.mean() * (1 - self.A)
Loading
Loading