esda.G

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

Global G Autocorrelation Statistic

Parameters:
wW

DistanceBand W spatial weights based on distance band

Notes

Moments are based on normality assumption.

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

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

Examining the results

>>> round(g.G, 3)
0.557
>>> round(g.p_norm, 3)
0.173
Attributes:
wW

DistanceBand W spatial weights based on distance band

vector of G values for permutated samples

null: spatial randomness alternative: the observed G is extreme it is either extremely high or extremely low

__init__(y, w, permutations=999)[source]

Methods

__init__(y, w[, permutations])

by_col(df, cols[, w, inplace, pvalue, outvals])

Function to compute a G statistic on a dataframe

classmethod by_col(df, cols, w=None, inplace=False, pvalue='sim', outvals=None, **stat_kws)[source]

Function to compute a G statistic on a dataframe

Parameters:
is searched for in the dataframe’s metadata

return a series contaning the results of the computation. If operating inplace, the derived columns will be named ‘column_g’

the G statistic’s documentation for available p-values

documentation for the G statistic.

Returns:
the relevant columns attached.