[R-sig-Geo] Compute Local Moran using Matrix Algebra
Roger Bivand
Roger.Bivand at nhh.no
Tue Jul 3 11:09:56 CEST 2012
On Mon, 2 Jul 2012, riaarinda wrote:
> 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).
Have you looked at the code of the localmoran() function? There you see:
b2 <- (sum(z^4, na.rm=NAOK)/n)/(s2^2)
as a (sort of) measure of kurtosis.
Roger
> 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.
>
> _______________________________________________
> 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