Learn R Programming

spdep (version 0.1-10)

moran.test: Moran's I test for spatial autocorrelation

Description

Moran's test for spatial autocorrelation using a spatial weights matrix in weights list form. The assumptions underlying the test are sensitive to the form of the graph of neighbour relationships and other factors, and results may be checked against those of moran.mc permutations.

Usage

moran.test(x, listw, randomisation=TRUE, zero.policy=FALSE,
	alternative="greater", rank = FALSE, spChk=NULL)

Arguments

x
a numeric vector the same length as the neighbours list in listw
listw
a listw object created for example by nb2listw
randomisation
variance of I calculated under the assumption of randomisation, if FALSE normality
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.
rank
logical value - default FALSE for continuous variables, if TRUE, uses the adaptation of Moran's I for ranks suggested by Cliff and Ord (1981, p. 46)
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 assumption used for calculating the standard deviate.
  • data.namea character string giving the name(s) of the data.

References

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

See Also

moran, moran.mc

Examples

Run this code
data(oldcol)
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="W"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="B"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="C"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="S"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(COL.nb, style="W"),
 randomisation=FALSE)
colold.lags <- nblag(COL.nb, 3)
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(colold.lags[[2]],
 style="W"))
moran.test(spNamedVec("CRIME", COL.OLD), nb2listw(colold.lags[[3]],
 style="W"))
ranks <- rank(COL.OLD$CRIME)
names(ranks) <- rownames(COL.OLD)
moran.test(ranks, nb2listw(COL.nb, style="W"), rank=TRUE)

Run the code above in your browser using DataLab