contingency_coef() computes Pearson's contingency coefficient C
for a two-way contingency table.
Arguments
- x
A contingency table (of class
table).- detail
Logical. If
FALSE(default), return the estimate as a numeric scalar. IfTRUE, return a named numeric vector including confidence interval and p-value.- conf_level
A number between 0 and 1 giving the confidence level (default
0.95). Only used whendetail = TRUE. Set toNULLto omit the confidence interval.- digits
Number of decimal places used when printing the result (default
3). Only affects thedetail = TRUEoutput.- .include_se
Internal parameter; do not use.
Value
Same structure as cramer_v(): a scalar when
detail = FALSE, a named vector when detail = TRUE.
The p-value tests the null hypothesis of no association
(Pearson chi-squared test). CI values are NA because no
standard asymptotic SE exists for C.
Details
The contingency coefficient is \(C = \sqrt{\chi^2 / (\chi^2 + n)}\). It ranges from 0 (independence) to a maximum that depends on the table dimensions. No standard asymptotic standard error exists, so the confidence interval is not computed.
See also
Other association measures:
assoc_measures(),
cramer_v(),
gamma_gk(),
goodman_kruskal_tau(),
kendall_tau_b(),
kendall_tau_c(),
lambda_gk(),
phi(),
somers_d(),
uncertainty_coef(),
yule_q()
Examples
tab <- table(sochealth$smoking, sochealth$education)
contingency_coef(tab)
#> [1] 0.1344361