Calculate Local Moran's I.

LocalMoransI(
  X,
  W,
  normalize = TRUE,
  alternative = c("two.sided", "less", "greater"),
  p.adjust.method = "BH",
  scale = TRUE
)

Arguments

X

A matrix with observations as rows and features as columns.

W

A weight matrix across all observations, i.e inverse of a pairwise distance matrix.

normalize

Whether to normalize the weight matrix such that each row adds up to one. Default is TRUE.

alternative

Alternative hypothesis used, default is two.sided.

p.adjust.method

Method used for multiple comparisons correction, default is BH. See p.adjust.

scale

Whether to scale the data. Default is TRUE.

Value

A list containing the following:

  • Local.Morans.I, the local Moran's I.

  • Z.I, the Z score of local Moran's I.

  • X, data matrix used for calculating local Moran's I.

  • Y, a matrix of spatial lags.

  • Expected.I, the expectation of Moran's I under the null hypothesis.

  • SD.I, the standard deviation of Moran's I under the null hypothesis.

  • p.val, p-values.

  • p.adj, adjusted p-values.

  • normalize, whether to normalize the weight matrix.

  • scale, whether to scale the data.

  • scale.factor, number of observations.

  • alternative, alternative hypothesis used.

  • p.adjust.method, method used for multiple comparisons correction.

References

Anselin, L. Local indicators of spatial association-LISA. Geogr. Anal. 27, 93–115 (1995) Sokal, R. R., Oden, N. L. & Thomson, B. A. Local spatial autocorrelation in a biological model. Geogr. Anal. 30, 331–354 (1998)

Examples

{
data.use <- quakes[1:100,]
W <- 1/as.matrix(dist(data.use[,1:2]))
diag(W) <- 0
res <- LocalMoransI(data.use[,3:4], W)
}