Skip to content
Prev 10839 / 29559 Next

listw for local Moran in spdep

On Tue, 8 Feb 2011, Agustin Lobo wrote:

            
Most of the use examples of cell2nb() are that one generates the nb object 
first to use in studying the properties of tests and estimators, because a 
grid on a torus has no edge effects. The positions are encoded in the 
"region.id" attribute of the nb object - the example in ?cell2nb shows 
their decoding to retreive coordinates corresponding to your case.

As I suggested, use rather dnearneigh:

require(spdep)
require(ncf)
xy <- expand.grid(x=1:20, y=1:5)
zori <- rmvn.spa(x=x, y=y, p=2, method="exp")
xy$z <- scale(zori)
coordinates(xy) <- c("x", "y")
wrz <- dnearneigh(xy, 0, sqrt(2))
wrz
lisarz = localmoran(x=xy$z, listw=nb2listw(wrz))
str(lisarz)

I'm assuming that rmvn.spa() outputs the vector in the correct order.

Roger