Learn R Programming

GeoXp (version 1.6.2)

nonormmoran: Detection of spatial autocorrelation

Description

The function nonnormmoran is used to detect spatial autocorrelation in the residuals $u$ from the least squares model $Y=beta X+u$. It calculates Moran's I statistic of the residuals based on the gaussian asymptotic distribution and give a p-value associated to the test of spatial autocorrelation (gaussian version).

Usage

nonormmoran(y, x, W)

Arguments

y
vector of size n of dependent variable
x
matrix $n x p$ containing explanatory variables
W
spatial weight matrix

Value

a list with nobs is the number of observations, nvar, the number of explanatory variables, morani is the Moran's I statistic estimate, imean is E(I), ivar is var(I), istat is the normalized Moran's I statistic (corresponding to $Z_i$), and prob the associated p-value.

Details

W is supposed standartized : $$I=(n/s)\frac{u'Wu}{u'u}$$ $$I \sim N(E(I),var(I))$$ let $M=(I-X(X'X)^(-1)X')$ $$E(I)=(n/s)\frac{tr(MW)}{n-k}$$ $$d=\frac{n-p}{n+p+2}$$ $$V(I)=(n/s)^2[tr(MWMW')+tr(MW)^2+(tr(MW))^2]/d-E(I)^2$$ $$Z_I=\frac{I-E(I)}{v(I)^{1/2}}$$

When W is row-normalised, $s=n$ else $s$ is the number of nonzero links

References

Thibault Laurent, Anne Ruiz-Gazen, Christine Thomas-Agnan (2012), GeoXp: An R Package for Exploratory Spatial Data Analysis. Journal of Statistical Software, 47(2), 1-23.

See Also

moranplotmap,neighbourmap,makeneighborsw,normw

Examples

Run this code
###
# data baltimore
data(baltimore)

# a spatial weight matrix constructed in the matrix format
W <- makeneighborsw(cbind(baltimore$X,baltimore$Y),method="neighbor",4)

# when W is not row-normalised ...
nonormmoran(baltimore$PRICE,cbind(rep(1,nrow(baltimore)),baltimore[,14:15]),W)
# when W is row_normalised ...
nonormmoran(baltimore$PRICE,cbind(rep(1,nrow(baltimore)),baltimore[,14:15]),normw(W))

# If we compare to the function lm.morantest
baltimore.lm<-lm(PRICE~LOTSZ+SQFT,data=baltimore)

lm.morantest(baltimore.lm, mat2listw(W))

Run the code above in your browser using DataLab