[R-sig-Geo] Compute Local Moran using Matrix Algebra
riaarinda
riaarinda at gmail.com
Mon Jul 2 18:35:39 CEST 2012
I am currently trying to compute local moran's (LISA) using matrix algebra. I
have already get the Ii and E(Ii) values (the result is correctly the same
with Geoda's), but now still confused about getting the Var.Ii, Z.Ii, and
Pr(z > 0). I am still confused about how to get b2 when I try to compute
V(Ii).
Anyone can help telling me how to compute them (Var.Ii, Z.Ii, and Pr(z >
0)), please.
Thank you
The code that I've been using :
library(spdep)
jateng.shp <-
readShapePoly('C:/Users/Toshiba/Documents/DATATIM/3/jateng.shp')
jateng.gal <- read.gal('C:/Users/Toshiba/Documents/DATATIM/3/jateng.gal')
jateng.nb <- nb2listw(jateng.gal)
v1 <- jateng.shp$RCAP107
obs <- NROW(v1)
obs1 <- obs-1
obs2 <- obs-2
ll <- (obs-1)/obs
v1z <- v1-mean(v1)
new_sd_1 <- sd(v1)*ll
a <- v1z/new_sd_1
v1zsdv1 <- v1z/sd(v1)
b <- lag.listw(jateng.nb, v1zsdv1)
unilocmor <- a*b ###### Ii values
wadah <- c(1:obs)
for(i in 1:obs){wadah[i] <- sum(jateng.mat[i,])}
Wi <- wadah
EIi <- Wi/(obs-1) ###### EIi values
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Compute-Local-Moran-using-Matrix-Algebra-tp7580374.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list