
OTIS a01 causal pipeline + Toronto Crime Severity Index context
Source:R/otis_all_analyze.R
morie_otis_analyze_a01_with_csi_context.RdRuns 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 (
NULLloads it).- variant
CSI variant:
"total"or"violent".- rebase_to_year
Anchor year for the CSI index column (default 2023). Use
NULLto skip rebasing.- tps_data
Optional named list of TPS incident data frames, one per CSI category (names from
MORIE_TPS_CSI_CATEGORIES()), each with anOCC_YEARcolumn.NULLloads them withmorie_tps_load_dataset; categories that fail to load are listed in the warnings.- out_dir
Optional output directory.
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"
#>
# }