inequality.gini.Gini_Spatial

class inequality.gini.Gini_Spatial(x, w, permutations=99)[source]

Spatial Gini coefficient.

Provides for computationally based inference regarding the contribution of spatial neighbor pairs to overall inequality across a set of regions. See [RS13].

Parameters:
ynumpy.array

An array in the shape \((n,1)\) containing the attribute values.

wlibpysal.weights.W

Binary spatial weights object.

permutationsint (default 99)

The number of permutations for inference.

Examples

>>> import libpysal
>>> import numpy
>>> from inequality.gini import Gini_Spatial

Use data from the 32 Mexican States, decade frequency 1940-2010.

>>> f = libpysal.io.open(libpysal.examples.get_path('mexico.csv'))
>>> vnames = [f'pcgdp{dec}' for dec in range(1940, 2010, 10)]
>>> y = numpy.transpose(numpy.array([f.by_col[v] for v in vnames]))

Define regime neighbors.

>>> regimes = numpy.array(f.by_col('hanson98'))
>>> w = libpysal.weights.block_weights(regimes, silence_warnings=True)
>>> numpy.random.seed(12345)
>>> gs = Gini_Spatial(y[:,0], w)
>>> gs.p_sim
0.04
>>> gs.wcg
4353856.0
>>> gs.e_wcg
4170356.7474747472

Thus, the amount of inequality between pairs of states that are not in the same regime (neighbors) is significantly higher than what is expected under the null of random spatial inequality.

Attributes:
gfloat

Gini coefficient.

wgfloat

Neighbor inequality component (geographic inequality).

wcgfloat

Non-neighbor inequality component (geographic complement inequality).

wcg_sharefloat

Share of inequality in non-neighbor component.

p_simfloat

(If permuations > 0) pseudo \(p\)-value for spatial gini.

e_wcgfloat

(If permuations > 0) expected value of non-neighbor inequality component (level) from permutations.

s_wcgfloat

(If permuations > 0) standard deviation non-neighbor inequality component (level) from permutations.

z_wcgfloat

(If permuations > 0) z-value non-neighbor inequality component (level) from permutations.

p_z_simfloat

(If permuations > 0) pseudo \(p\)-value based on standard normal approximation of permutation based values.

__init__(x, w, permutations=99)[source]

Methods

__init__(x, w[, permutations])