How to calculate local autocorrelation via Geary's C in R?

635 Views Asked by At

Calculating local autocorrelation via Moran's I is easy with the localmoran() function from the package spdep. But is it possible to calculate Geary's coefficient for local autocorrelation in R? I know that this is possible in GeoDa, but I have no idea how to do that in R.

1

There are 1 best solutions below

1
On

To calculate the local Geary's C, there is no function or package in R that does it so far ( In fact there is the function usdm::lisa(), but it calculates it for Raster data). I have created a simple script for this and compared it with GeoDa and the values are similar. It is this:

Map < rgdal::readOGR("./Map.shp")
neighbours <- spdep::poly2nb(Map)
wq <- spdep::nb2listw(neighbours,style = "W")
W.matrix <- as(wq, "CsparseMatrix") # Matrix of space weights - queen
var <- scale(Map$var)[,1]
n <- length(Map) # number of neighbourhoods or polygons

CG <- numeric(n) 
for (i in c(1:n)) {
  CG[i] <- sum(W.matrix[i,] * (var [i] - var)^2)
}

This gives us the local Geary's C, but to know if it is significant or not, it is necessary to perform a permutation test. I recommend reading the article "A Local Indicator of Multivariate Spatial Association: Extending Geary's c" by Luc Anselin (2018).