[R-sig-Geo] Help with defining local spatial clustering: local.moran
Corey Sparks
corey.sparks at utsa.edu
Thu Apr 22 05:03:25 CEST 2010
Hello all,
I have a question that I hope the list may be able to help with.
So I understand how the LISA application of the Local Moran statistic
works in terms of calculating local moran's I. The thing I'm wrestling
with is how, say in GeoDA or ArcGIS, the local clusters are defined
and mapped. Say you
have an area that is a high-high cluster, I'm assuming that this is an
area that has a high z-score for the attribute, and a high z-score for
the lagged value of the attribute. Although the local.moran function
will calculate the local estimate of the moran's I, but how can you go
about mapping the type of local cluster.
If I were to do this in R, I would
do something like:
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")
[1], IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
sid.nb<-poly2nb(xx)
lw<-nb2listw(sid.nb)
xx$rt79<-xx$SID79/xx$BIR79
my.moran<-function (x, listw, zero.policy = FALSE)
{
require(RColorBrewer)
require(spdep)
wx<-lag.listw(listw, x)
lag.z<-scale(wx, center=T, scale=T)
dat.z<-scale(x, center=T, scale=T)
mor.dat<-data.frame(lz=lag.z, z=dat.z)
mor.dat$clusters<-"UN"
mor.dat$clusters[mor.dat$lz>1&mor.dat$z>1]<-"HH" #both z scores
are "high"
mor.dat$clusters[mor.dat$lz< -1&mor.dat$z< -1]<-"LL" #both z
scores are "low"
mor.dat$clusters[mor.dat$lz>1&mor.dat$z< -1]<-"LH" #one z score
high, the other low
mor.dat$clusters[mor.dat$lz< -1&mor.dat$z>1]<-"HL"
#Where UN = unclustered, HH=high/high, HL=high/low, LH=low/high,
LL=low/low
cols<-brewer.pal(5, "RdBu")
mor.dat$col[mor.dat$clusters=="UN"]<-cols[3]
mor.dat$col[mor.dat$clusters=="HH"]<-cols[1]
mor.dat$col[mor.dat$clusters=="LL"]<-cols[5]
mor.dat$col[mor.dat$clusters=="HL"]<-cols[2]
mor.dat$col[mor.dat$clusters=="LH"]<-cols[4]
mor.dat
}
test<-my.moran(xx$rt79, lw)
plot(xx, col=test$col)
Is this effectively what geoda/arc-gis, etc that makes these cluster
plots is doing? I know that this is not based on a randomisation
methodology, and am pretty sure i'm missing something, but i'm just
trying to answer the rudimentary question on how the local clusters
are defined and mapped.
Any advice would be welcomed.
Thanks,
Corey Sparks
Corey Sparks
Assistant Professor
Department of Demography and Organization Studies
College of Public Policy
501 West Durango Blvd
Monterrey Building 2.270C
San Antonio, TX 78207
corey.sparks 'at' utsa.edu
210 458 3166
More information about the R-sig-Geo
mailing list