This function assesses the degree of spatial autocorrelation present in regression residuals by means of the Moran coefficient.

MI.resid(resid, x = NULL, W, alternative = "greater", boot = NULL)

Arguments

resid

residual vector

x

vector/ matrix of regressors (default = NULL)

W

spatial connectivity matrix

alternative

specification of alternative hypothesis as 'greater' (default), 'lower', or 'two.sided'

boot

optional integer specifying the number of simulation iterations to compute the variance. If NULL (default), variance calculated under assumed normality

Value

A data.frame object with the following elements:

I

observed value of the Moran coefficient

EI

expected value of Moran's I

VarI

variance of Moran's I

zI

standardized Moran coefficient

pI

p-value of the test statistic

Details

The function assumes an intercept-only model if x = NULL. Furthermore, MI.resid automatically symmetrizes the matrix W by: 1/2 * (W + W').

Note

Calculations are based on the procedure proposed by Cliff and Ord (1981). See also Cliff and Ord (1972).

References

Cliff, Andrew D. and John K. Ord (1981): Spatial Processes: Models & Applications. Pion, London.

Cliff, Andrew D. and John K. Ord (1972): Testing for Spatial Autocorrelation Among Regression Residuals. Geographical Analysis, 4 (3): pp. 267 - 284

Author

Sebastian Juhl

Examples

data(fakedata)
y <- fakedataset$x1
x <- fakedataset$x2

resid <- y - x %*% solve(crossprod(x)) %*% crossprod(x,y)
(Moran <- MI.resid(resid = resid, x = x, W = W, alternative = "greater"))
#>          I         EI       VarI       zI          pI   
#> 1 0.245404 -0.0119261 0.01207299 2.341981 0.009590855 **

# intercept-only model
x <- rep(1, length(y))
resid2 <- y - x %*% solve(crossprod(x)) %*% crossprod(x,y)
intercept <- MI.resid(resid = resid2, W = W, alternative = "greater")
# same result with MI.vec for the intercept-only model
vec <- MI.vec(x = resid2, W = W, alternative = "greater")
rbind(intercept, vec)
#>           I          EI        VarI       zI           pI    
#> 1 0.3111782 -0.01010101 0.005344193 4.394825 5.543107e-06 ***
#> 2 0.3111782 -0.01010101 0.005344193 4.394825 5.543107e-06 ***