Learn R Programming

spdep (version 0.1-10)

lm.morantest: Moran's I test for residual spatial autocorrelation

Description

Moran's I test for spatial autocorrelation in residuals from an estimated linear model (lm()). The helper function listw2U() constructs a weights list object corresponding to the sparse matrix $\frac{1}{2} ( \mathbf{W} + \mathbf{W}'$

Usage

lm.morantest(model, listw, zero.policy=FALSE, 
	    alternative = "greater", spChk=NULL)
listw2U(listw)

Arguments

model
an object of class lm returned by lm; weights and offsets should not be used
listw
a listw object created for example by nb2listw
zero.policy
if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA
alternative
a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.
spChk
should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use get.spChkOption()

Value

  • A list with class htest containing the following components:
  • statisticthe value of the standard deviate of Moran's I.
  • p.valuethe p-value of the test.
  • estimatethe value of the observed Moran's I, its expectation and variance under the method assumption.
  • alternativea character string describing the alternative hypothesis.
  • methoda character string giving the method used.
  • data.namea character string giving the name(s) of the data.

References

Cliff, A. D., Ord, J. K. 1981 Spatial processes, Pion, p. 203,

See Also

lm.LMtests, lm

Examples

Run this code
data(oldcol)
oldcrime1.lm <- lm(CRIME ~ 1, data = COL.OLD)
oldcrime.lm <- lm(CRIME ~ HOVAL + INC, data = COL.OLD)
lm.morantest(oldcrime.lm, nb2listw(COL.nb, style="W"))
lm.LMtests(oldcrime.lm, nb2listw(COL.nb, style="W"))
lm.morantest(oldcrime.lm, nb2listw(COL.nb, style="S"))
lm.morantest(oldcrime1.lm, nb2listw(COL.nb, style="W"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="W"),
 randomisation=FALSE)

Run the code above in your browser using DataLab