
Chi-square: charges-recommended independent of year?
Source:R/siu_analyze.R
morie_siu_charges_by_year_chi2.RdCross-tabulates charges_recommended against incident-year
and tests independence with a Pearson chi-square (
stats::chisq.test; p-value via stats::pchisq). Years with
zero charge-decided cases are dropped. Complements
morie_siu_verify_chi2 in sprott_doob.R, which
tests specific published 2x2 tables; this is a generic "did the
charge rate move?" probe over the harvested SIU corpus.
Arguments
- data
Either a data frame (e.g. the output of
morie_fetch_siu()read in) or a path toSIU_by_case.csv.NULL(the default) looks infile.path(tempdir(), "morie", "siu", "SIU_by_case.csv").
Examples
df <- data.frame(
date_of_incident_iso = rep(c("2022-01-01", "2023-01-01", "2024-01-01"), each = 4),
charges_recommended = rep(c(TRUE, FALSE, FALSE, TRUE), 3))
r <- morie_siu_charges_by_year_chi2(df)
r$title
#> [1] "SIU charges-recommended vs. year (chi-square)"