inequality.theil.TheilD#
- class inequality.theil.TheilD(y, partition, column=None)[source]#
Decomposition of Theil’s T based on partitioning of observations into exhaustive and mutually exclusive groups.
- Parameters:
- y
numpy.array,pandas.Series,orpandas.DataFrame An array in the shape \((n,t)\) or \((n,)\) with \(n\) taken as the observations across which inequality is calculated. If
yis \((n,)\) then a scalar inequality value is determined. Ifyis \((n,t)\) then an array of inequality values are determined, one value for each column iny. For apandas.DataFrame, passcolumn(a name or list of names) to select the values.- partitionarray_like or
pandas.Series An array in the shape \((n,)\) of elements indicating which partition each observation belongs to. These are assumed to be exhaustive.
- column
strorlistofstr,optional Name(s) of the column(s) holding the values when
yis apandas.DataFrame.
- y
- 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
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 ])
Methods
__init__(y, partition[, column])