pysal.explore.giddy.rank.SpatialTau

class pysal.explore.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:
x : array

(n, ), first variable.

y : array

(n, ), second variable.

w : W

spatial weights object.

permutations : int

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 [Rey14] for details.

Examples

>>> import pysal.lib as ps
>>> import numpy as np
>>> from pysal.explore.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:
tau : float

The classic Tau statistic.

tau_spatial : float

Value of Tau for pairs that are spatial neighbors.

taus : array

(permtuations, 1), values of simulated tau_spatial values under random spatial permutations in both periods. (Same permutation used for start and ending period).

pairs_spatial : int

Number of spatial pairs.

concordant : float

Number of concordant pairs.

concordant_spatial : float

Number of concordant pairs that are spatial neighbors.

extraX : float

Number of extra X pairs.

extraY : float

Number of extra Y pairs.

discordant : float

Number of discordant pairs.

discordant_spatial : float

Number of discordant pairs that are spatial neighbors.

taus : float

spatial tau values for permuted samples (if permutations>0).

tau_spatial_psim : float

one-sided pseudo p-value for observed tau_spatial under the null of spatial randomness of rank exchanges (if permutations>0).

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

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(x, y, w[, permutations]) Initialize self.