esda.G

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

Global G Autocorrelation Statistic

Parameters:
y : array (n,1)

Attribute values

w : W | Graph

spatial weights instance as W or Graph aligned with y

permutations : int

the number of random permutations for calculating pseudo p_values

y[source]

original variable

Type:

array

w[source]

spatial weights instance as W or Graph aligned with y

Type:

W

permutation[source]

the number of permutations

Type:

int

G[source]

the value of statistic

Type:

float

EG[source]

the expected value of statistic

Type:

float

VG[source]

the variance of G under normality assumption

Type:

float

z_norm[source]

standard normal test statistic

Type:

float

p_norm[source]

p-value under normality assumption (one-sided)

Type:

float

sim[source]

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

Type:

array

p_sim[source]

p-value based on permutations (one-sided) null: spatial randomness alternative: the observed G is extreme it is either extremely high or extremely low

Type:

float

EG_sim[source]

average value of G from permutations

Type:

float

VG_sim[source]

variance of G from permutations

Type:

float

seG_sim[source]

standard deviation of G under permutations.

Type:

float

z_sim[source]

standardized G based on permutations

Type:

float

p_z_sim[source]

p-value based on standard normal approximation from permutations (one-sided)

Type:

float

Notes

Moments are based on normality assumption.

For technical details see [Getis and Ord, 2010] and [Ord and Getis, 2010].

Examples

>>> import libpysal
>>> 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 = libpysal.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 esda import G
>>> g = G(y, w)

Examining the results

>>> round(g.G, 3)
np.float64(0.557)
>>> round(g.p_norm, 3)
np.float64(0.173)