0

请找到随附的 R 代码。

library(maptools)
library(spdep)
library(leaflet)
library(RColorBrewer)

#Read polygon shapefile from the directory
chi.poly <- readShapePoly('Immunization.shp')
class(chi.poly)
str(slot(chi.poly,"data"))
summary(chi.poly@data$bcg)
plot(chi.poly)

chi.ols<-lm(bcg~ib+pnc+full_anc, data=chi.poly@data)
summary(chi.ols)

list.queen<-poly2nb(chi.poly, queen=TRUE)
W<-nb2listw(list.queen, style="W", zero.policy=T)
W
moran.lm<-lm.morantest(chi.ols, W, alternative="two.sided")
print(moran.lm)

**主要问题是这些地区有一些无邻域的空间点。因此,当我尝试通过生成的空间权重矩阵计算 moran's I 索引时,它显示了无邻域的错误。

我没有得到,如果一些空间点没有邻居,如何调整空间权重矩阵。

请帮帮我。提前致谢

4

0 回答 0