[R-sig-eco] Help with autocorrelation: Local Moran's I

Meghan Hutchins meghan.hutchins at gmail.com
Wed Jul 21 03:42:22 CEST 2010


Hi,

I am running an agent-based model that outputs grid coordinates and
values from a 6x6 cellular grid. I am then using R to read in this
data from a .csv file. The coordinates are in the form: (1,1), (1,2),
(1,3) etc and the individual cell values will vary.

I would like to know if there is any spatial autocorrelation between a
grid cell and its "rook" neighbors. I am thinking that a Local Moran's
I is the way to go. I installed the "spdep" package, but I can't quite
figure out how to use the localmoran method. This is what I have:

some.nb <- cell2nb(6, 6, type="rook", torus=FALSE)
valueList <- myGridData$values
resI <- localmoran( valueList, nb2listw(some.nb) )

Mainly, I'm confused by the some.nb "neighbor list object" and how it
is relating to my one dimensional list of values. My thought is that
some.nb is being used as a type of template for the valueList? If so
how does the method assign actual values to the neighbor list object?
There seems to be a very good chance I'm missing something.

Any help or advice is greatly appreciated.

Thanks so much in advance,
Meghan Hutchins



More information about the R-sig-ecology mailing list