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: |
|
---|
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: |
|
---|