This function assesses the degree of spatial autocorrelation present in regression residuals by means of the Moran coefficient.
vector/ matrix of regressors (default = NULL)
spatial connectivity matrix
specification of alternative hypothesis as 'greater' (default), 'lower', or 'two.sided'
optional integer specifying the number of simulation iterations to compute the variance. If NULL (default), variance calculated under assumed normality
The function assumes an intercept-only model if
x = NULL.
MI.resid automatically symmetrizes the matrix
W by: 1/2 * (W + W').
data.frame object with the following elements:
observed value of the Moran coefficient
expected value of Moran's I
variance of Moran's I
standardized Moran coefficient
p-value of the test statistic
Calculations are based on the procedure proposed by Cliff and Ord (1981). See also Cliff and Ord (1972).
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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")) # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.