Skip to content
Back to formatted view

Raw Message

Message-ID: <D4554399-0016-4384-91FA-F685EE43BEFA@ieu.uzh.ch>
Date: 2018-08-16T11:44:54Z
From: Dechen Lham
Subject: Morans I

hi all,

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

#get coordinates first
coords<-as.matrix(cbind(data$long,data$lat))

#model
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.