The Local Geary is a local adaptation of Geary's C statistic of spatial autocorrelation. The Local Geary uses squared differences to measure dissimilarity unlike the Local Moran. Low values of the Local Geary indicate positive spatial autocorrelation and large refers to negative spatial autocorrelation. Inference for the Local Geary is based on a permutation approach which compares the observed value to the reference distribution under spatial randomness. The Local Geary creates a pseudo p-value. This is not an analytical p-value and is based on the number of permutations and as such should be used with care.

## Arguments

- x
a numeric vector, or list of numeric vectors of equal length.

- nb
a neighbor list

- wt
a weights list

- ...
other arguments passed to

`spdep::localC_perm()`

, e.g.`zero.policy = TRUE`

to allow for zones without neighbors.- nsim
The number of simulations used to generate reference distribution.

- alternative
A character defining the alternative hypothesis. Must be one of "two.sided", "less" or "greater".

## Value

a `data.frame`

with columns

`ci`

: Local Geary statistic`e_ci`

: expected value of the Local Geary based on permutations`z_ci`

: standard deviation based on permutations`var_ci`

: variance based on permutations`p_ci`

: p-value based on permutation sample standard deviation and means`p_ci_sim`

: p-value based on rank of observed statistic`p_folded_sim`

: p-value based on the implementation of Pysal which always assumes a two-sided test taking the minimum possible p-value`skewness`

: sample skewness`kurtosis`

: sample kurtosis

## Details

### Overview

The Local Geary can be extended to a multivariate context. When `x`

is a numeric vector, the univariate Local Geary will be calculated. To calculate the multivariate Local Moran provide either a list or a matrix. When `x`

is a list, each element must be a numeric vector of the same length and of the same length as the neighbours in `listw`

. In the case that `x`

is a matrix the number of rows must be the same as the length of the neighbours in `listw`

.

While not required in the univariate context, the standardized Local Geary is calculated. The multivariate Local Geary is *always* standardized.

The univariate Local Geary is calculated as \(c_i = \sum_j w_{ij}(x_i - x_j)^2\) and the multivariate Local Geary is calculated as \(c_{k,i} = \sum_{v=1}^{k} c_{v,i}\) as described in Anselin (2019).

### Implementation

These functions are based on the implementations of the local Geary statistic in the development version of spdep. They are based on spdep::localC and spdep::localC_perm.

spdep::localC_perm and thus local_c_perm utilize a conditional permutation approach to approximate a reference distribution where each observation `i`

is held fixed, randomly samples neighbors, and calculated the local C statistic for that tuple (`ci`

). This is repeated `nsim`

times. From the simulations 3 different types of p-values are calculated—all of which have their potential flaws. So be *extra judicious* with using p-values to make conclusions.

`p_ci`

: utilizes the sample mean and standard deviation. The p-value is then calculated using`pnorm()`

--assuming a normal distribution which isn't always true.`p_ci_sim`

: uses the rank of the observed statistic.`p_folded_sim`

: follows the pysal implementation where p-values are in the range of [0, 0.5]. This excludes 1/2 of all p-values and should be used with caution.

## References

Anselin, L. (1995), Local Indicators of Spatial Association—LISA. Geographical Analysis, 27: 93-115. doi: 10.1111/j.1538-4632.1995.tb00338.x

Anselin, L. (2019), A Local Indicator of Multivariate Spatial Association: Extending Geary's c. Geogr Anal, 51: 133-150. doi: 10.1111/gean.12164

## Author

Josiah Parry, josiah.parry@gmail.com

## Examples

```
g <- dplyr::transmute(guerry,
nb = st_contiguity(geometry),
wt = st_weights(nb),
geary = local_c_perm(
x = list(crime_pers, literacy), nb, wt)
)
tidyr::unnest(g, geary)
#> Simple feature collection with 85 features and 12 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 47680 ymin: 1703258 xmax: 1031401 ymax: 2677441
#> CRS: NA
#> # A tibble: 85 × 13
#> nb wt ci cluster e_ci var_ci z_ci p_ci p_ci_…¹ p_fol…² skewn…³
#> <nb> <list> <dbl> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 <int> <dbl> 1.09 Positi… 1.79 0.502 -0.993 0.321 0.32 0.16 0.625
#> 2 <int> <dbl> 0.557 Positi… 1.56 0.214 -2.17 0.0299 0.028 0.014 0.241
#> 3 <int> <dbl> 0.571 Positi… 2.62 0.729 -2.40 0.0164 0.008 0.004 0.380
#> 4 <int> <dbl> 0.525 Positi… 1.57 0.438 -1.57 0.116 0.076 0.038 0.362
#> 5 <int> <dbl> 1.69 Positi… 2.57 1.10 -0.841 0.401 0.42 0.21 0.171
#> 6 <int> <dbl> 0.803 Positi… 2.29 0.531 -2.04 0.0417 0.024 0.012 0.317
#> 7 <int> <dbl> 1.99 Positi… 4.59 1.90 -1.89 0.0587 0.032 0.016 0.262
#> 8 <int> <dbl> 1.09 Positi… 3.56 2.13 -1.69 0.0915 0.032 0.016 0.664
#> 9 <int> <dbl> 0.547 Positi… 1.65 0.321 -1.95 0.0510 0.04 0.02 0.379
#> 10 <int> <dbl> 0.557 Positi… 1.25 0.287 -1.30 0.193 0.172 0.086 0.650
#> # … with 75 more rows, 2 more variables: kurtosis <dbl>,
#> # geometry <MULTIPOLYGON>, and abbreviated variable names ¹p_ci_sim,
#> # ²p_folded_sim, ³skewness
#> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
```