MI.resid: Moran Test for Residual Spatial Autocorrelation

View source: R/MI.resid.R

MI.residR Documentation

Moran Test for Residual Spatial Autocorrelation

Description

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

Usage

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

Details

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

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

Note

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

Author(s)

Sebastian Juhl

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

See Also

lmFilter, glmFilter, MI.vec, MI.local

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"))

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


spfilteR documentation built on Aug. 23, 2022, 1:06 a.m.