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.
Asked
Active
Viewed 568 times
0
-
3Looks like some interesting hits for "Geary's coefficient for local autocorrelation in R" as a web search. – Dec 19 '17 at 16:32
-
1That was useful, but the links mostly point out to either a global measure, or just to the formula. Thank you for the answer – Tzvetan Moev Dec 19 '17 at 17:59
-
`terra::autocor` has local Geary for raster data. – Robert Hijmans Nov 28 '21 at 05:50
1 Answers
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

Andres Montaña
- 11
- 1
-
1This 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