Skip to contents

Cross-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.

Usage

morie_siu_charges_by_year_chi2(data = NULL)

Arguments

data

Either a data frame (e.g. the output of morie_fetch_siu() read in) or a path to SIU_by_case.csv. NULL (the default) looks in file.path(tempdir(), "morie", "siu", "SIU_by_case.csv").

Value

A morie_rich_result list including the contingency table, statistic, df, and p-value.

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