inequality.theil.TheilD

class inequality.theil.TheilD(y, partition)[source]

Decomposition of Theil’s T based on partitioning of observations into exhaustive and mutually exclusive groups.

Parameters:
ynumpy.array

An array in the shape \((n,t)\) or \((n,)\) with \(n\) taken as the observations across which inequality is calculated. If y is \((n,)\) then a scalar inequality value is determined. If y is \((n,t)\) then an array of inequality values are determined, one value for each column in y.

partitionnumpy.array

An array in the shape \((n,)\) of elements indicating which partition each observation belongs to. These are assumed to be exhaustive.

Examples

>>> import libpysal
>>> import numpy
>>> from inequality.theil import TheilD
>>> f = libpysal.io.open(libpysal.examples.get_path('mexico.csv'))
>>> vnames = [f'pcgdp{dec}' for dec in range(1940, 2010, 10)]
>>> y = numpy.array([f.by_col[v] for v in vnames]).T
>>> regimes = numpy.array(f.by_col('hanson98'))
>>> theil_d = TheilD(y, regimes)
>>> theil_d.bg
array([0.0345889 , 0.02816853, 0.05260921, 0.05931219, 0.03205257,
       0.02963731, 0.03635872])
>>> theil_d.wg
array([0.17435454, 0.12405598, 0.0521202 , 0.04263506, 0.06354856,
       0.07547525, 0.0702496 ])
Attributes:
Tnumpy.array

An array in the shape \((t,)\) or \((1,)\) containing the global inequality T.

bgnumpy.array

An array in the shape \((n,t)\) or \((n,)\) representing between group inequality.

wgnumpy.array

An array in the shape \((n,t)\) or \((n,)\) representing within group inequality.

__init__(y, partition)[source]

Methods

__init__(y, partition)