# esda.Geary¶

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

Global Geary C Autocorrelation statistic

Parameters:
y`array`

(n, 1) attribute vector

w`W` | `Graph`

spatial weights instance as W or Graph aligned with y

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.

permutations`int`

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
>>> 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:
y`array`

original variable

w`W` | `Graph`

spatial weights

permutations`int`

number of permutations

C`float`

value of statistic

EC`float`

expected value

VC`float`

variance of G under normality assumption

z_norm`float`

z-statistic for C under normality assumption

z_rand`float`

z-statistic for C under randomization assumption

p_norm`float`

p-value under normality assumption (one-tailed)

p_rand`float`

p-value under randomization assumption (one-tailed)

sim`array`

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

p_sim`float`

(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_sim`float`

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

VC_sim`float`

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

seC_sim`float`

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

z_sim`float`

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

p_z_sim`float`

(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:
df`pandas.DataFrame`

a pandas dataframe with a geometry column

cols

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

w`pysal` `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’

pvalue`str`

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

outvals`list` of `strings`

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

**stat_kws`dict`

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].