pysal.explore.inequality.theil.Theil

class pysal.explore.inequality.theil.Theil(y)[source]

Classic Theil measure of inequality

\[T = \sum_{i=1}^n \left( \frac{y_i}{\sum_{i=1}^n y_i} \ln \left[ N \frac{y_i}{\sum_{i=1}^n y_i}\right] \right)\]
Parameters:
y : array (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.

Notes

This computation involves natural logs. To prevent ln[0] from occurring, a small value is added to each element of y before beginning the computation.

Examples

>>> import pysal.lib
>>> import numpy as np
>>> from pysal.explore.inequality.theil import Theil
>>> f=pysal.lib.io.open(pysal.lib.examples.get_path("mexico.csv"))
>>> vnames=["pcgdp%d"%dec for dec in range(1940,2010,10)]
>>> y=np.array([f.by_col[v] for v in vnames]).T
>>> theil_y=Theil(y)
>>> theil_y.T
array([0.20894344, 0.15222451, 0.10472941, 0.10194725, 0.09560113,
       0.10511256, 0.10660832])
Attributes:
T : array (t,) or (1,)

Theil’s T for each column of y

__init__(y)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(y) Initialize self.