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:
- y
numpy.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. Ify
is \((n,t)\) then an array of inequality values are determined, one value for each column iny
.- partition
numpy.array
An array in the shape \((n,)\) of elements indicating which partition each observation belongs to. These are assumed to be exhaustive.
- y
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:
- T
numpy.array
An array in the shape \((t,)\) or \((1,)\) containing the global inequality T.
- bg
numpy.array
An array in the shape \((n,t)\) or \((n,)\) representing between group inequality.
- wg
numpy.array
An array in the shape \((n,t)\) or \((n,)\) representing within group inequality.
- T
Methods
__init__
(y, partition)