pysal.explore.esda.G

class pysal.explore.esda.G(y, w, permutations=999)[source]

Global G Autocorrelation Statistic

Parameters:
y : array (n,1)

Attribute values

w : W

DistanceBand W spatial weights based on distance band

permutations : int

the number of random permutations for calculating pseudo p_values

Notes

Moments are based on normality assumption.

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) >>> w.transform = “B”

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

Applying Getis and Ord G test >>> from pysal.explore.esda.getisord import G >>> g = G(y,w)

Examining the results >>> round(g.G, 3) 0.557

>>> round(g.p_norm, 3)
0.173
Attributes:
y : array

original variable

w : W

DistanceBand W spatial weights based on distance band

permutation : int

the number of permutations

G : float

the value of statistic

EG : float

the expected value of statistic

VG : float

the variance of G under normality assumption

z_norm : float

standard normal test statistic

p_norm : float

p-value under normality assumption (one-sided)

sim : array

(if permutations > 0) vector of G values for permutated samples

p_sim : float

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

average value of G from permutations

VG_sim : float

variance of G from permutations

seG_sim : float

standard deviation of G under permutations.

z_sim : float

standardized G based on permutations

p_z_sim : float

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 statistic on a dataframe
__init__(y, w, permutations=999)[source]

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

Methods

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