Skip to contents

Convenience 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
)

Arguments

data

Polygon-level data.frame.

year_cols

Character vector of per-year count column names (e.g. c("ASSAULT_2014", ..., "ASSAULT_2024")).

lat_col, lon_col, k, n_permutations, seed

as in mrm_tps_lisa.

Value

data.frame with columns year, n_events, moran_I, global_p_value.

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