# nonormmoran: Detection of spatial autocorrelation In GeoXp: Interactive exploratory spatial data analysis

## 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

 `1` ```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

## 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

## 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.

## Note

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.

## Author(s)

Translated into R from Jim Lessage's Spatial Econometrics Toolbox, http://www.spatial-econometrics.com/

## 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.

`moranplotmap`,`neighbourmap`,`makeneighborsw`,`normw`
 ``` 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)) ```