yule_q() computes Yule's Q coefficient of association for a 2x2
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 H0: Q = 0 (Wald z-test).
Details
For a 2x2 table with cells \(a, b, c, d\), Yule's Q is
\(Q = (ad - bc) / (ad + bc)\).
It is equivalent to the Goodman-Kruskal Gamma for 2x2 tables.
The asymptotic standard error is
\(SE = 0.5 (1 - Q^2) \sqrt{1/a + 1/b + 1/c + 1/d}\).
Standard error formulas follow the DescTools implementations
(Signorell et al., 2024); see cramer_v() for full references.
Examples
tab <- table(sochealth$smoking, sochealth$sex)
yule_q(tab)
#> [1] -0.02632653
