For aggregate contingency tables, rmorie exposes
morie_chi_square_test() and the companion effect-size
helpers (Cramer’s V, omega-squared).
library(rmorie)
tab <- matrix(c(20, 10, 30,
15, 25, 35), nrow = 2, byrow = TRUE,
dimnames = list(group = c("treated", "control"),
outcome = c("A", "B", "C")))
result <- morie_chi_square_test(tab)
result$chi_sq
#> [1] 5.934066
result$p_value
#> [1] 0.05145575
result$df
#> [1] 2
result$cramers_v
#> [1] 0.209657morie_chi_square_test() returns a list with the Pearson
\(\chi^{2}\) (chi_sq), the
degrees of freedom, the asymptotic p-value, and Cramer’s V. The values
agree with stats::chisq.test(tab).
Cramer’s V scales the chi-square statistic to a 0–1 association measure that is more interpretable than the raw statistic.
For continuous outcomes across more than two groups, the one-way
ANOVA pattern in R is aov(y ~ g, data = ...). MORIE exposes
morie_omega_squared() as the less-biased counterpart to
eta-squared:
set.seed(2)
n <- 90
group <- rep(c("A", "B", "C"), each = n / 3)
y <- rnorm(n) + ifelse(group == "C", 0.6, 0)
fit <- stats::aov(y ~ group)
fsum <- summary(fit)[[1]]
fstat <- fsum$`F value`[1]
df_b <- fsum$Df[1]
df_w <- fsum$Df[2]
fstat
#> [1] 0.9152736
morie_omega_squared(f_stat = fstat, df_between = df_b, df_within = df_w, n = n)
#> [1] -0.00188636With this seed the F statistic is below 1, so omega-squared comes out slightly negative. The estimator allows that; read a negative value as an effect indistinguishable from zero.
morie_siu_verify_published_chi_squares() recomputes five
Pearson chi-square statistics from contingency tables transcribed from
the 2021 Sprott–Doob and Sprott–Doob–Iftene reports on federal
Structured Intervention Units, and compares each with the published
value:
v <- morie_siu_verify_published_chi_squares()
v$tables[[1]]$data
#> source recomputed_chi2 recomputed_df
#> 1 SD-2021-Feb T11 Region x stay length 201.01 16
#> 2 SD-2021-Feb T15 Region x MH 27.51 4
#> 3 SD-2021-Feb T22 Region x Mandela 208.54 8
#> 4 SDI-2021-May T5 Race x #reviews 8.50 3
#> 5 SDI-2021-May T10 Per-IEDM 26.12 11
#> published_chi2 published_df pass
#> 1 201.00 16 TRUE
#> 2 27.51 4 TRUE
#> 3 208.54 8 TRUE
#> 4 8.50 3 TRUE
#> 5 26.12 11 TRUEeffect-sizes vignette covers Cohen’s d, Cramer’s V,
omega-squared, proportion confidence intervals, and the E-value.mrm_otis_mortification_cooccurrence() applies the
chi-square test and Cramer’s V to pairs of OTIS alert flags; see the
mrm-empirical-callables vignette.