[R-sig-Geo] Morans I

Roger Bivand Roger@Biv@nd @ending from nhh@no
Sat Sep 1 12:13:35 CEST 2018


On Thu, 16 Aug 2018, Dechen Lham wrote:

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

No, certainly not correct; speculations suggest that using lm.morantest() 
is less unsure, but I cannot find the reference at the moment. When 
testing residuals from a linear model, the whole model output is needed 
(see reference in ?lm.morantest) and this extends to glm models.

Roger

>
>
> Advise from experts using function moran.test will be much appreciated.
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



More information about the R-sig-Geo mailing list