giddy.rank.Tau_Local_Neighborhood

class giddy.rank.Tau_Local_Neighborhood(x, y, w, permutations=0)[source]

Neighborhood set LIMA.

An extension of neighbor set LIMA. Consider local concordance relationships for a subset of states, defined as the focal state and its neighbors.

Parameters:
xarray

(n, ), first variable.

yarray

(n, ), second variable.

wW

spatial weights object.

permutationsint

number of random spatial permutations for computationally based inference.

Notes

The equation for calculating neighborhood set LIMA statistic can be found in [Rey16] Equation (22).

Examples

>>> import libpysal as ps
>>> from giddy.rank import Tau_Local_Neighborhood
>>> import numpy as np
>>> np.random.seed(10)
>>> f = ps.io.open(ps.examples.get_path("mexico.csv"))
>>> vnames = ["pcgdp%d"%dec for dec in range(1940, 2010, 10)]
>>> y = np.transpose(np.array([f.by_col[v] for v in vnames]))
>>> r = y / y.mean(axis=0)
>>> regime = np.array(f.by_col['esquivel99'])
>>> w = ps.weights.block_weights(regime)
>>> res = Tau_Local_Neighborhood(r[:,0],r[:,1],w,permutations=999)
>>> res.tau_lnhood
array([0.06666667, 0.6       , 0.2       , 0.8       , 0.33333333,
       0.6       , 0.6       , 0.2       , 1.        , 0.06666667,
       0.06666667, 0.33333333, 0.33333333, 0.2       , 1.        ,
       0.33333333, 0.33333333, 0.2       , 0.6       , 0.33333333,
       0.33333333, 0.06666667, 0.8       , 0.06666667, 0.2       ,
       0.6       , 0.8       , 0.6       , 0.33333333, 0.8       ,
       0.8       , 0.06666667])
>>> res.tau_lnhood_pvalues
array([0.106, 0.33 , 0.107, 0.535, 0.137, 0.414, 0.432, 0.169, 1.   ,
       0.03 , 0.019, 0.146, 0.249, 0.1  , 0.908, 0.225, 0.311, 0.125,
       0.399, 0.215, 0.334, 0.115, 0.669, 0.045, 0.11 , 0.525, 0.655,
       0.466, 0.236, 0.413, 0.504, 0.038])
>>> res.sign
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
Attributes:
nint

number of observations.

tau_localarray

(n, ), local concordance (local version of the classic tau).

Sarray

(n ,n), concordance matrix, s_{i,j}=1 if observation i and j are concordant, s_{i, j}=-1 if observation i and j are discordant, and s_{i,j}=0 otherwise.

tau_lnhoodarray

(n, ), observed neighborhood set LIMA values.

tau_lnhood_simarray

(n, permutations), neighborhood set LIMA values for permuted samples (if permutations>0).

tau_lnhood_pvaluesarray

(n, 1), one-sided pseudo p-values for observed neighborhood set LIMA values under the null that the concordance relationships for a subset of states, defined as the focal state and its neighbors, is different from what would be expected from randomly distributed rank changes.

signarray

(n, ), values indicate concordant or disconcordant: 1 concordant, -1 disconcordant

__init__(x, y, w, permutations=0)[source]

Methods

__init__(x, y, w[, permutations])