Per-year global Moran's I time series across a polygon surface
Source:R/mrm_lisa.R
mrm_tps_polygon_moran_per_year.RdConvenience wrapper that loops mrm_tps_lisa over a vector
of per-year count columns.
Usage
mrm_tps_polygon_moran_per_year(
data,
year_cols,
lat_col = "lat",
lon_col = "lon",
k = 6L,
n_permutations = 999L,
seed = 42L
)Examples
# 4 x 4 polygon grid with two yearly count columns.
set.seed(2026)
grid <- expand.grid(
lat = 43.6 + (0:3) * 0.02,
lon = -79.4 + (0:3) * 0.02
)
grid$ASSAULT_2023 <- rpois(nrow(grid), lambda = grid$lat * 10)
grid$ASSAULT_2024 <- rpois(nrow(grid), lambda = grid$lat * 12)
res <- mrm_tps_polygon_moran_per_year(
grid,
year_cols = c("ASSAULT_2023", "ASSAULT_2024"),
lat_col = "lat", lon_col = "lon",
k = 4L, n_permutations = 99L, seed = 42L
)
res
#> year n_events moran_I global_p_value
#> 1 2023 6908 0.0122 0.97
#> 2 2024 8483 0.0084 0.96