moran

moran(x, coords, scaled = FALSE, alternative = "two.sided")

Arguments

x

numeric vector of responses

coords

Matrix of coordinates corresponding to values in X, can also be data frame that the distance matrix is generated from

scaled

Boolean, whether to use scaled (standardized) values

alternative

Character string containing the name of residual variable

Value

A list including the observed and expected statistic, standard error, and p-value

Examples

# \donttest{
set.seed(2021)
d <- data.frame(
  X = runif(1000), Y = runif(1000),
  year = sample(1:10, size = 1000, replace = TRUE)
)
d$density <- rnorm(0.01 * d$X - 0.001 * d$X * d$X + d$Y * 0.02 - 0.005 * d$Y * d$Y, 0, 0.1)
moran_stat <- moran(d$density, coords = d[, c("X", "Y")])
# }