Calculate permutation based p-value for Moran's I.

PermutationMoransI(
  x,
  W,
  n = 999,
  seed = 1,
  normalize = TRUE,
  return.permutation = FALSE
)

Arguments

x

A numerical vector.

W

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

n

The number of permutations to be conducted, set to 999 by default.

seed

Random seed used. Default is 1.

normalize

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

return.permutation

Return permutations. Default is FALSE.

Value

A list containing the following:

  • Morans.I, the Moran's I.

  • p.val, permutation based p-value.

  • return.permutation, permutation used if returned.

Examples

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