Learn R Programming

spdep (version 0.1-10)

globalG.test: test for spatial autocorrelation

Description

.

Usage

globalG.test(x, listw, zero.policy=FALSE, alternative="greater",
 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
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 statistic, its expectation and variance.
  • alternativea character string describing the alternative hypothesis.
  • data.namea character string giving the name(s) of the data.

References

Getis. A, Ord, J. K. 1992 The analysis of spatial association by use of distance statistics, Geographical Analysis, 24, p. 195.

See Also

localG

Examples

Run this code
data(nc.sids)
sidsrate79 <- (1000*nc.sids$SID79)/nc.sids$BIR79
names(sidsrate79) <- rownames(nc.sids)
dists <- c(10, 20, 30, 33, 40, 50, 60, 70, 80, 90, 100)
ndists <- length(dists)
ZG <- numeric(length=ndists)
milesxy <- cbind(nc.sids$east, nc.sids$north)
for (i in 1:ndists) {
  thisnb <- dnearneigh(milesxy, 0, dists[i], row.names=rownames(nc.sids))
  thislw <- nb2listw(thisnb, style="B", zero.policy=TRUE)
  ZG[i] <- globalG.test(sidsrate79, thislw, zero.policy=TRUE)$statistic
}
cbind(dists, ZG)

Run the code above in your browser using DataLab