0

使用 spdep 包中的 localmoran() 函数可以很容易地通过 Moran's I 计算局部自相关。但是是否可以计算 R 中局部自相关的 Geary 系数?我知道这在 GeoDa 中是可能的,但我不知道如何在 R 中做到这一点。

4

1 回答 1

1

要计算本地 Geary 的 C,到目前为止,R 中还没有函数或包可以做到这一点(实际上有函数 usdm::lisa(),但它为 Raster 数据计算它)。我为此创建了一个简单的脚本,并将其与 GeoDa 进行了比较,并且值相似。它是这个:

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

这给了我们当地的 Geary's C,但要知道它是否显着,有必要执行置换检验。我建议阅读 Luc Anselin(2018 年)的文章“多元空间关联的局部指标:扩展 Geary 的 c”。

于 2021-11-27T23:08:14.247 回答