Detection of spatial autocorrelation
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).
nonormmoran(y, x, W)
vector of size n of dependent variable
matrix n x p containing explanatory variables
spatial weight matrix
W is supposed standartized :
I sim N(E(I),var(I))
When W is row-normalised, s=n else s is the number of nonzero links
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.
This function is closed to the function
lm.morantest included in the spdep package.
nonnormmoran is less confortable to use because it didn't take into account S4 classes.
Translated into R from Jim Lessage's Spatial Econometrics Toolbox, http://www.spatial-econometrics.com/
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
### # 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))
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.