phi() computes the phi coefficient for a 2x2 contingency table.
phi(x, detail = FALSE, conf_level = 0.95, digits = 3L, .include_se = FALSE)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).
A contingency table (of class table).
Logical. If FALSE (default), return the estimate
as a numeric scalar. If TRUE, return a named numeric vector
including confidence interval and p-value.
A number between 0 and 1 giving the confidence
level (default 0.95). Only used when detail = TRUE. Set
to NULL to omit the confidence interval.
Number of decimal places used when printing the
result (default 3). Only affects the detail = TRUE output.
Internal parameter; do not use.
The phi coefficient is \(\phi = \sqrt{\chi^2 / n}\).
It is equivalent to Cramer's V for 2x2 tables and equals the
Pearson correlation between the two binary variables. The point
estimate matches the DescTools (Signorell et al., 2024) and SPSS
implementations.
The confidence interval uses the Fisher z-transformation on
\(\phi\); see cramer_v() for the formula and full references.
cramer_v(), yule_q(), assoc_measures()
Other association measures:
assoc_measures(),
contingency_coef(),
cramer_v(),
gamma_gk(),
goodman_kruskal_tau(),
kendall_tau_b(),
kendall_tau_c(),
lambda_gk(),
somers_d(),
uncertainty_coef(),
yule_q()
tab <- table(sochealth$smoking, sochealth$sex)
phi(tab)
phi(tab, detail = TRUE)
Run the code above in your browser using DataLab