# pysal.explore.esda.G_Local¶

class pysal.explore.esda.G_Local(y, w, transform='R', permutations=999, star=False)[source]

Generalized Local G Autocorrelation

Parameters: y : array variable w : W DistanceBand, weights instance that is based on threshold distance and is assumed to be aligned with y transform : {‘R’, ‘B’} the type of w, either ‘B’ (binary) or ‘R’ (row-standardized) permutations : int the number of random permutations for calculating pseudo p values star : boolean whether or not to include focal observation in sums (default: False)

Notes

To compute moments of Gs under normality assumption, PySAL considers w is either binary or row-standardized. For binary weights object, the weight value for self is 1 For row-standardized weights object, the weight value for self is 1/(the number of its neighbors + 1).

For technical details see [GO10] and [OG10].

Examples

>>> import pysal.lib
>>> import numpy
>>> numpy.random.seed(10)


Preparing a point data set

>>> points = [(10, 10), (20, 10), (40, 10), (15, 20), (30, 20), (30, 30)]


Creating a weights object from points

>>> w = pysal.lib.weights.DistanceBand(points,threshold=15)


Prepareing a variable

>>> y = numpy.array([2, 3, 3.2, 5, 8, 7])


Applying Getis and Ord local G test using a binary weights object

>>> from pysal.explore.esda.getisord import G_Local
>>> lg = G_Local(y,w,transform='B')


Examining the results

>>> lg.Zs
array([-1.0136729 , -0.04361589,  1.31558703, -0.31412676,  1.15373986,
1.77833941])
>>> round(lg.p_sim[0], 3)
0.101

>>> numpy.random.seed(10)


Applying Getis and Ord local G* test using a binary weights object >>> lg_star = G_Local(y,w,transform=’B’,star=True)

Examining the results >>> lg_star.Zs array([-1.39727626, -0.28917762, 0.65064964, -0.28917762, 1.23452088,

2.02424331])
>>> round(lg_star.p_sim[0], 3)
0.101

>>> numpy.random.seed(12345)


Applying Getis and Ord local G test using a row-standardized weights object >>> lg = G_Local(y,w,transform=’R’)

Examining the results >>> lg.Zs array([-0.62074534, -0.01780611, 1.31558703, -0.12824171, 0.28843496,

1.77833941])
>>> round(lg.p_sim[0], 3)
0.103

>>> numpy.random.seed(10)


Applying Getis and Ord local G* test using a row-standardized weights object

>>> lg_star = G_Local(y,w,transform='R',star=True)


Examining the results >>> lg_star.Zs array([-0.62488094, -0.09144599, 0.41150696, -0.09144599, 0.24690418,

1.28024388])
>>> round(lg_star.p_sim[0], 3)
0.101

Attributes: y : array original variable w : DistanceBand W original weights object permutations : int the number of permutations Gs : array of floats, the value of the orginal G statistic in Getis & Ord (1992) EGs : float expected value of Gs under normality assumption the values is scalar, since the expectation is identical across all observations VGs : array of floats, variance values of Gs under normality assumption Zs : array of floats, standardized Gs p_norm : array of floats, p-value under normality assumption (one-sided) for two-sided tests, this value should be multiplied by 2 sim : array of arrays of floats (if permutations>0), vector of I values for permutated samples p_sim : array of floats, p-value based on permutations (one-sided) null - spatial randomness alternative - the observed G is extreme it is either extremely high or extremely low EG_sim : array of floats, average value of G from permutations VG_sim : array of floats, variance of G from permutations seG_sim : array of floats, standard deviation of G under permutations. z_sim : array of floats, standardized G based on permutations p_z_sim : array of floats, p-value based on standard normal approximation from permutations (one-sided)

Methods

 by_col(df, cols[, w, inplace, pvalue, outvals]) Function to compute a G_Local statistic on a dataframe
 calc
__init__(y, w, transform='R', permutations=999, star=False)[source]

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

Methods

 __init__(y, w[, transform, permutations, star]) Initialize self. by_col(df, cols[, w, inplace, pvalue, outvals]) Function to compute a G_Local statistic on a dataframe calc()