Skip to contents

Computes local Moran's Ii for each neighbourhood given a k-NN spatial weights graph on centroid lat/long, with HH / LL / HL / LH quadrant classification.

Usage

morie_tps_local_morans_i(
  df,
  hood_col = "HOOD_158",
  ds_name = "?",
  k_neighbours = 5L,
  top_n = 20L,
  lat_col = "LAT_WGS84",
  lon_col = "LONG_WGS84"
)

Arguments

df

Incident-level data.frame.

hood_col

Neighbourhood id column.

ds_name

Tag for the result title.

k_neighbours

k for the spatial weights graph.

top_n

Number of top-Ii rows to surface in the result table.

lat_col, lon_col

WGS84 column names.

Value

A named list with table (data.frame of per-hood I_i, z, Wz, quadrant) and quadrant tallies.

Examples

set.seed(2026)
df <- data.frame(
  HOOD_158 = sample(letters[1:15], 300, replace = TRUE),
  LAT_WGS84 = 43.6 + runif(300, 0, 0.2),
  LONG_WGS84 = -79.4 + runif(300, 0, 0.2)
)
morie_tps_local_morans_i(df, top_n = 5L)
#> LISA (local Moran's Ii) -- ?
#> ============================
#> Call: morie_tps_local_morans_i(df=<300r>, hood_col=HOOD_158, k=5) 
#> 
#>   Spatial unit               HOOD_158
#>   Neighbourhoods             15
#>   Hot spots (HH)             5
#>   Cold spots (LL)            2
#>   HL outliers (high-in-low)  3
#>   LH outliers (low-in-high)  5
#> 
#> LISA identified 5 hot-spot (HH) and 2 cold-spot (LL) neighbourhood(s) on a k=5-NN graph (n=15). HL outliers (high count surrounded by low neighbours) = 3, LH = 5. Top neighbourhood by local Ii: 'm' with Ii=+0.811.