esda.Geary

class esda.Geary(y, w, transformation='r', permutations=999)[source]

Global Geary C Autocorrelation statistic

Parameters:
yarray

(n, 1) attribute vector

wW

spatial weights

transformation{‘R’, ‘B’, ‘D’, ‘U’, ‘V’}

weights transformation, default is row-standardized. Other options include “B”: binary, “D”: doubly-standardized, “U”: untransformed (general weights), “V”: variance-stabilizing.

permutationsint

number of random permutations for calculation of pseudo-p_values

Notes

Technical details and derivations can be found in [CO81].

Examples

>>> import libpysal
>>> from esda.geary import Geary
>>> w = libpysal.io.open(libpysal.examples.get_path("book.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("book.txt"))
>>> y = np.array(f.by_col['y'])
>>> c = Geary(y,w,permutations=0)
>>> round(c.C,7)
0.3330108
>>> round(c.p_norm,7)
9.2e-05
>>>
Attributes:
yarray

original variable

wW

spatial weights

permutationsint

number of permutations

Cfloat

value of statistic

ECfloat

expected value

VCfloat

variance of G under normality assumption

z_normfloat

z-statistic for C under normality assumption

z_randfloat

z-statistic for C under randomization assumption

p_normfloat

p-value under normality assumption (one-tailed)

p_randfloat

p-value under randomization assumption (one-tailed)

simarray

(if permutations!=0) vector of I values for permutated samples

p_simfloat

(if permutations!=0) p-value based on permutations (one-tailed) null: sptial randomness alternative: the observed C is extreme it is either extremely high or extremely low

EC_simfloat

(if permutations!=0) average value of C from permutations

VC_simfloat

(if permutations!=0) variance of C from permutations

seC_simfloat

(if permutations!=0) standard deviation of C under permutations.

z_simfloat

(if permutations!=0) standardized C based on permutations

p_z_simfloat

(if permutations!=0) p-value based on standard normal approximation from permutations (one-tailed)

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

Methods

__init__(y, w[, transformation, permutations])

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

Function to compute a Geary statistic on a dataframe

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

Function to compute a Geary statistic on a dataframe

Parameters:
dfpandas.DataFrame

a pandas dataframe with a geometry column

colsstr or list of str

name or list of names of columns to use to compute the statistic

wpysal weights object

a weights object aligned with the dataframe. If not provided, this is searched for in the dataframe’s metadata

inplacebool

a boolean denoting whether to operate on the dataframe inplace or to return a series contaning the results of the computation. If operating inplace, with default configurations, the derived columns will be named like ‘column_geary’ and ‘column_p_sim’

pvaluestr

a string denoting which pvalue should be returned. Refer to the the Geary statistic’s documentation for available p-values

outvalslist of strings

list of arbitrary attributes to return as columns from the Geary statistic

**stat_kwsdict

options to pass to the underlying statistic. For this, see the documentation for the Geary statistic.

Returns:
If inplace, None, and operation is conducted on dataframe in memory. Otherwise,
returns a copy of the dataframe with the relevant columns attached.

Notes

Technical details and derivations can be found in [CO81].