For aggregate contingency tables \u2014 the kind that sit behind the Doob
\(\chi^{2}\) family in the MRM
framework \u2014 MORIE exposes chi_square_test() and the
companion effect-size helpers (Cramer\u2019s V, omega-squared) as first-class
functions.
library(morie)
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 <- chi_square_test(tab)
result$statistic
#> NULL
result$p_value
#> [1] 0.05145575
result$df
#> [1] 2
chi_square_test() returns the Pearson \(\chi^{2}\), the asymptotic p-value, and the
degrees of freedom in a tidy list.
v <- cramers_v(tab)
v
#> [1] 0.209657
Cramer\u2019s V scales the chi-square statistic to a 0\u20131 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
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]
omega_squared(f_stat = fstat, df_between = df_b, df_within = df_w, n = n)
#> [1] -0.00188636
The MRM framework\u2019s \u201cDoob \(\chi^{2}\) family\u201d is a coordinated set of
chi-square tests on the published Sprott / Doob / Iftene contingency
tables (federal SIU operation, COVID-period operation,
torture-classification rates, IEDM analyses). MORIE reproduces all five
published statistics to within \(0.01\)
of the printed values; details are in the MRM paper
(citation("morie")).
effect-sizes vignette covers Cohen\u2019s d, Cramer\u2019s V,
omega-squared, proportion-CI, and the E-value in one place.mrm-otis-walkthrough vignette shows the chi-square
family applied to OTIS provincial data.