MI.resid: Moran Test for Residual Spatial Autocorrelation

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/MI.resid.R

Description

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

Usage

1
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

 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)

spfilteR documentation built on Oct. 5, 2021, 9:10 a.m.