Please find the R codes attached herewith.
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)
**The main issue is that the districts have some neighbourless spatial points. Thus when I am trying to compute moran's I index through the generated spatial weight matrix, it is showing an error of neighbourless regions.
I am not getting, how to adjust the spatial weight matrix in case of some of the spatial points having no neighbors.
Please help me out. Thanks in advance