0

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 Answers1

1

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

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • 1
    This answer would be much more useful if you made the script reproducible by using the example data that comes with R (eg. the N Carolina data) and included the necessary `library()` calls. – Robert Hijmans Nov 28 '21 at 05:49