moran | R Documentation |
moran
moran(x, coords, scaled = FALSE, alternative = "two.sided")
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 |
A list including the observed and expected statistic, standard error, and p-value
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")])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.