Morans I

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Morans I

Dechen Lham
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.
_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Morans I

Roger Bivand
Administrator
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
> [hidden email]
> 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: [hidden email]
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway