kendall_tau_b() computes Kendall's Tau-b for a two-way
contingency table of ordinal variables.
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 single number strictly between 0 and 1 giving the confidence level (default
0.95). Only used whendetail = TRUE. Set toNULLto omit the confidence interval. Any other value – including percentages such as95– raises a classed error (spicy_invalid_input).- digits
Number of decimal places used when printing the result (default
3). Only affects thedetail = TRUEoutput.
Value
Same structure as cramer_v(): a scalar when
detail = FALSE, a named vector when detail = TRUE.
The p-value tests H0: tau-b = 0 (Wald z-test).
Details
Kendall's Tau-b is computed as
\(\tau_b = (C - D) / \sqrt{(n_0 - n_1)(n_0 - n_2)}\),
where \(n_0 = n(n-1)/2\), \(n_1\) is the number of
pairs tied on the row variable, and \(n_2\) is the number
tied on the column variable. Tau-b corrects for ties and is
appropriate for square tables.
When the asymptotic standard error is zero (e.g. a perfect
association), the Wald z-test is undefined and the p-value is
NA, matching the other measures in the family.
The asymptotic standard error is the Brown and Benedetti (1977)
ASE1, as printed by SPSS / PSPP CROSSTABS. It deliberately
diverges from DescTools::KendallTauB(), whose implementation
mis-scales one margin term of the gradient; see cramer_v()
for full references.
References
Kendall, M. G. (1938). A new measure of rank correlation. Biometrika, 30(1-2), 81-93. doi:10.2307/2332226
Brown, M. B., & Benedetti, J. K. (1977). Sampling behavior of tests for correlation in two-way contingency tables. Journal of the American Statistical Association, 72(358), 309-315. doi:10.1080/01621459.1977.10480995
See also
kendall_tau_c(), gamma_gk(), somers_d(),
assoc_measures()
Other association measures:
assoc_measures(),
contingency_coef(),
cramer_v(),
gamma_gk(),
goodman_kruskal_tau(),
kendall_tau_c(),
lambda_gk(),
phi(),
somers_d(),
uncertainty_coef(),
yule_q()
Examples
tab <- table(sochealth$education, sochealth$self_rated_health)
kendall_tau_b(tab)
#> [1] 0.2045524