Reputation: 11
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.
Upvotes: 0
Views: 709
Reputation: 11
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).
Upvotes: 1