Skip to contents

Runs morie_otis_analyze_a01 (alert complexity -> regional volatility, MatchIt then IRM-DML) and sets it beside Toronto's Crime Severity Index for the OTIS years (2023-2025), computed with morie_tps_csi_per_year from TPS incident tables. The question it frames: did the OTIS effect arise while Toronto crime severity was rising or falling?

Usage

morie_otis_analyze_a01_with_csi_context(
  data = NULL,
  variant = "total",
  rebase_to_year = 2023L,
  tps_data = NULL,
  out_dir = NULL
)

Arguments

data

Optional a01 data frame (NULL loads it).

variant

CSI variant: "total" or "violent".

rebase_to_year

Anchor year for the CSI index column (default 2023). Use NULL to skip rebasing.

tps_data

Optional named list of TPS incident data frames, one per CSI category (names from MORIE_TPS_CSI_CATEGORIES()), each with an OCC_YEAR column. NULL loads them with morie_tps_load_dataset; categories that fail to load are listed in the warnings.

out_dir

Optional output directory.

Value

morie_otis_analysis_result.

Examples

# \donttest{
a01 <- morie_synth_otis("a01", n = 300L, seed = 1L)
cats <- MORIE_TPS_CSI_CATEGORIES()
tps <- stats::setNames(lapply(seq_along(cats), function(i)
  data.frame(OCC_YEAR = rep(2022:2025, times = 10 * i))), cats)
r <- morie_otis_analyze_a01_with_csi_context(a01, tps_data = tps)
r$tables[[1L]]$rows
#> [[1]]
#> [1] "2023"     "452370"   "450"      "14687.34" "100"     
#> 
#> [[2]]
#> [1] "2024"     "452370"   "450"      "14550.34" "99.07"   
#> 
#> [[3]]
#> [1] "2025"     "452370"   "450"      "14420.47" "98.18"   
#> 
# }