Effect size for contingency tables
Compute Cramer's V, phi (φ), Cohen's w (an alias of phi), Odds ratios, Risk ratios, Cohen's h and Cohen's g for contingency tables or goodness-of-fit. See details.
phi(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...) cohens_w(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...) cramers_v(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...) oddsratio(x, y = NULL, ci = 0.95, log = FALSE, ...) riskratio(x, y = NULL, ci = 0.95, log = FALSE, ...) cohens_h(x, y = NULL, ci = 0.95, ...) cohens_g(x, y = NULL, ci = 0.95, ...)
x |
a numeric vector or matrix. |
y |
a numeric vector; ignored if |
ci |
Confidence Interval (CI) level |
adjust |
Should the effect size be bias-corrected? Defaults to |
CI |
Deprecated in favor of |
... |
Arguments passed to |
log |
Take in or output the log of the ratio (such as in logistic models). |
Cramer's V and phi (φ) are effect sizes for tests of independence
in 2D contingency tables, or for goodness-of-fit in 1D tables. For 2-by-2
tables, they are identical, and are equal to the simple correlation between
two dichotomous variables, ranging between 0 (no dependence) and 1 (perfect
dependence). For larger tables, Cramer's V should be used, as it is bounded
between 0-1, whereas phi can be larger than 1.
For 2-by-2 contingency tables, Odds ratios, Risk ratios and Cohen's h can
also be estimated. Note that these are computed with each column
representing the different groups, and the first column representing the
treatment group and the second column baseline (or control). Effects are
given as treatment / control
. If you wish you use rows as groups you must
pass a transposed table, or switch the x
and y
arguments.
Cohen's g is an effect size for dependent (paired) contingency tables
ranging between 0 (perfect symmetry) and 0.5 (perfect asymmetry) (see
stats::mcnemar.test()
).
A data frame with the effect size (Cramers_v
, phi
(possibly with
the suffix _adjusted
), Odds_ratio
, Risk_ratio
(possibly with the
prefix log_
), Cohens_h
, or Cohens_g
) and its CIs (CI_low
and
CI_high
).
For Cohen's g, confidence intervals are based on the proportion (P = g
+ 0.5) confidence intervals returned by stats::prop.test()
(minus 0.5),
which give a good close approximation.
For Odds ratios, Risk ratios and Cohen's h, confidence intervals are
estimated using the standard normal parametric method (see Katz et al., 1978;
Szumilas, 2010).
See Confidence Intervals and CI Contains Zero sections for phi, Cohen's
w and Cramer's V.
Unless stated otherwise, confidence intervals are estimated using the
Noncentrality parameter method; These methods searches for a the best
non-central parameters (ncp
s) of the noncentral t-, F- or Chi-squared
distribution for the desired tail-probabilities, and then convert these
ncp
s to the corresponding effect sizes. (See full effectsize-CIs for
more.)
For positive only effect sizes (Eta squared, Cramer's V, etc.; Effect sizes associated with Chi-squared and F distributions), special care should be taken when interpreting CIs with a lower bound equal to 0, and even more care should be taken when the upper bound is equal to 0 (Steiger, 2004; Morey et al., 2016). For example:
eta_squared(aov(mpg ~ factor(gear) + factor(cyl), mtcars[1:7, ]))
## Parameter | Eta2 (partial) | 90% CI ## -------------------------------------------- ## factor(gear) | 0.58 | [0.00, 0.84] ## factor(cyl) | 0.46 | [0.00, 0.78]
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd Ed.). New York: Routledge.
Katz, D. J. S. M., Baptista, J., Azen, S. P., & Pike, M. C. (1978). Obtaining confidence intervals for the risk ratio in cohort studies. Biometrics, 469-474.
Szumilas, M. (2010). Explaining odds ratios. Journal of the Canadian academy of child and adolescent psychiatry, 19(3), 227.
chisq_to_phi()
for details regarding estimation and CIs.
Other effect size indices:
cohens_d()
,
effectsize()
,
eta_squared()
,
rank_biserial()
,
standardize_parameters()
M <- rbind( c(150, 130, 35, 55), c(100, 50, 10, 40), c(165, 65, 2, 25) ) dimnames(M) <- list( Study = c("Psych", "Econ", "Law"), Music = c("Pop", "Rock", "Jazz", "Classic") ) M phi(M) cramers_v(M) ## 2-by-2 tables ## ------------- (RCT <- matrix( c( 71, 30, 50, 100 ), nrow = 2, byrow = TRUE, dimnames = list( Diagnosis = c("Sick", "Recovered"), Group = c("Treatment", "Control") ) )) # note groups are COLUMNS oddsratio(RCT) riskratio(RCT) cohens_h(RCT) ## Dependent (Paired) Contingency Tables ## ------------------------------------- Performance <- rbind( c(794, 86), c(150, 570) ) dimnames(Performance) <- list( "1st Survey" = c("Approve", "Disapprove"), "2nd Survey" = c("Approve", "Disapprove") ) Performance cohens_g(Performance)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.