[R-sig-Geo] moran.plot: sum or mean?
Roger Bivand
Roger.Bivand at nhh.no
Mon Apr 22 21:27:22 CEST 2013
On Mon, 22 Apr 2013, Robert J. Hijmans wrote:
> I am using package spdep. I have a listw object (lw) and a vector of
> values (y) and I want to make a Moran scatterplot (with unadjusted
> values):
>
> library(spdep)
> m <- matrix(c(0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0,
> 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0), ncol=6)
> lw <- mat2listw(m, style='B')
> y <- c(32, 26, 19, 14, 18, 17)
> moran.plot(y, lw)
>
> # The values on the vertical axes are the sums of the lagged values
> # (as returned by lag(lw, y) ), where I expected the mean (which is
> # what the example ?moran.plot example appears to do
>
>
> # I expected this
> x <- cbind(rep(y, each=6), as.vector(m * y))
> x <- x[x[,2] > 0, ]
> x <- aggregate(x[,2], list(x[,1]), FUN=mean)
> colnames(x) <- c('y', 'lagged y')
>
> # and a plot like this
> x11()
> plot(x)
> abline(lm(x[,2] ~ x[,1]), lwd=2)
> abline(v=mean(y), lt=2)
> abline(h=mean(x[,2]), lt=2)
>
>
> # What am I missing?
Row standardisation of the weights object:
moran.plot(y, mat2listw(m, style='W'))
which authors of the Moran scatterplot literature tend to take for
granted, see references in ?moran.plot, especially the top of p. 116 in
Anselin 1996.
Hope this clarifies,
Roger
>
> Thanks, Robert
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list