giddy.rank.SpatialTau¶
- class giddy.rank.SpatialTau(x, y, w, permutations=0)[source]¶
Spatial version of Kendall’s rank correlation statistic.
Kendall’s Tau is based on a comparison of the number of pairs of n observations that have concordant ranks between two variables. The spatial Tau decomposes these pairs into those that are spatial neighbors and those that are not, and examines whether the rank correlation is different between the two sets relative to what would be expected under spatial randomness.
- Parameters:
- xarray
(n, ), first variable.
- yarray
(n, ), second variable.
- wW
spatial weights object.
- permutationsint
number of random spatial permutations for computationally based inference.
Notes
Algorithm has two stages. The first calculates classic Tau using a list based implementation of the algorithm from [Chr05]. Second stage calculates concordance measures for neighboring pairs of locations using a modification of the algorithm from [PTVF07]. See [Rey14a] for details.
Examples
>>> import libpysal as ps >>> import numpy as np >>> from giddy.rank import SpatialTau >>> 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])) >>> regime=np.array(f.by_col['esquivel99']) >>> w=ps.weights.block_weights(regime) >>> np.random.seed(12345) >>> res=[SpatialTau(y[:,i],y[:,i+1],w,99) for i in range(6)] >>> for r in res: ... ev = r.taus.mean() ... "%8.3f %8.3f %8.3f"%(r.tau_spatial, ev, r.tau_spatial_psim) ... ' 0.397 0.659 0.010' ' 0.492 0.706 0.010' ' 0.651 0.772 0.020' ' 0.714 0.752 0.210' ' 0.683 0.705 0.270' ' 0.810 0.819 0.280'
- Attributes:
- taufloat
The classic Tau statistic.
- tau_spatialfloat
Value of Tau for pairs that are spatial neighbors.
- tausarray
(permtuations, 1), values of simulated tau_spatial values under random spatial permutations in both periods. (Same permutation used for start and ending period).
- pairs_spatialint
Number of spatial pairs.
- concordantfloat
Number of concordant pairs.
- concordant_spatialfloat
Number of concordant pairs that are spatial neighbors.
- extraXfloat
Number of extra X pairs.
- extraYfloat
Number of extra Y pairs.
- discordantfloat
Number of discordant pairs.
- discordant_spatialfloat
Number of discordant pairs that are spatial neighbors.
- tausfloat
spatial tau values for permuted samples (if permutations>0).
- tau_spatial_psimfloat
one-sided pseudo p-value for observed tau_spatial under the null of spatial randomness of rank exchanges (if permutations>0).
Methods
__init__
(x, y, w[, permutations])