[R-sig-Geo] Morans I

Dechen Lham dechen@lh@m @ending from ieu@uzh@ch
Thu Aug 16 13:44:54 CEST 2018

hi all,

is the below the correct way to access spatial autocorrelation using morans I in a glm:

#get coordinates first

m1 <- glm(response~ predictor1 + predictor 2+ predictor1*predictor2, family=binomial, data=data)

# Compute Moran's I using residuals of model
lstw <- nb2listw((knn2nb(knearneigh(coords, k=1))))

moran.test(residuals(m1), lstw) 

Advise from experts using function moran.test will be much appreciated. 

More information about the R-sig-Geo mailing list