giddy.rank.Tau_Local_Neighbor

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

Neighbor set LIMA.

Local concordance relationships between a focal unit and its neighbors. A decomposition of local Tau into neighbor and non-neighbor components.

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 neighbor set LIMA statistic can be found in [Rey16] Equation (16).

Examples

>>> import libpysal as ps
>>> import numpy as np
>>> from giddy.rank import Tau_Local_Neighbor, SpatialTau
>>> 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_Neighbor(r[:,0], r[:,1], w, permutations=999)
>>> res.tau_ln
array([-0.2       ,  1.        ,  1.        ,  1.        ,  0.33333333,
        0.6       ,  0.6       , -0.5       ,  1.        ,  1.        ,
        0.2       ,  0.33333333,  0.33333333,  0.5       ,  1.        ,
        1.        ,  1.        ,  0.        ,  0.6       , -0.33333333,
       -0.33333333, -0.6       ,  1.        ,  0.2       ,  0.        ,
        0.2       ,  1.        ,  0.6       ,  0.33333333,  0.5       ,
        0.5       , -0.2       ])
>>> res.tau_ln_weights
array([0.03968254, 0.03968254, 0.03174603, 0.03174603, 0.02380952,
       0.03968254, 0.03968254, 0.03174603, 0.00793651, 0.03968254,
       0.03968254, 0.02380952, 0.02380952, 0.03174603, 0.00793651,
       0.02380952, 0.02380952, 0.03174603, 0.03968254, 0.02380952,
       0.02380952, 0.03968254, 0.03174603, 0.03968254, 0.03174603,
       0.03968254, 0.03174603, 0.03968254, 0.02380952, 0.03174603,
       0.03174603, 0.03968254])
>>> res.tau_ln_pvalues
array([0.541, 0.852, 0.668, 0.568, 0.11 , 0.539, 0.609, 0.058, 1.   ,
       0.255, 0.125, 0.087, 0.393, 0.433, 0.908, 0.657, 0.447, 0.128,
       0.531, 0.033, 0.12 , 0.271, 0.868, 0.234, 0.124, 0.387, 0.859,
       0.697, 0.349, 0.664, 0.596, 0.041])
>>> 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])
>>> (res.tau_ln * res.tau_ln_weights).sum() #global spatial tau
0.39682539682539675
>>> res1 = SpatialTau(r[:,0],r[:,1],w,permutations=999)
>>> res1.tau_spatial
0.3968253968253968
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_lnarray

(n, ), observed neighbor set LIMA values.

tau_ln_weightsarray

(n, ), weights for neighbor set LIMA at each location. GIMA is the weighted average of neighbor set LIMA.

tau_ln_simarray

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

tau_ln_pvaluesarray

(n, ), one-sided pseudo p-values for observed neighbor set LIMA values under the null that concordance relationship between the focal state and itsn eighbors is not different from what could 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])