CAssociation · Guide test 079
Kendall tau test
Tests ordinal association using concordant and discordant observation pairs.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- Correlation matrix (Pearson / Spearman / Kendall) — How strongly do several numeric variables move together, pair by pair?
- Correlation test (Pearson / Spearman / Kendall) — Do two numeric variables move together, and how strongly?
In Correlation test (Pearson / Spearman / Kendall), choose Coefficient = Kendall τ_b (ranks, ties).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Kendall τ test
Alternative
Your data
Simulated with a known ρIf H₀ were true
- The reference: how T varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the total probability of outcomes no more likely than yours (p = .021).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- concordant and discordant pairs
- pairs tied in x and in y (both are 0 without ties, and then τ_b is τ_a)
- the number of concordant pairs (R's statistic for the exact test)
- all pairs
The verdict
T = 282, p = .021, τ = 0.30
p ≤ α = .050: reject H₀
Effect size: Kendall's tau τ = 0.297
τ is the difference between the chance two random pairs agree in order and the chance they disagree — an easy number to explain. Without ties R uses T's exact null distribution; with ties, a normal z. This bench follows R's defaults; the CodeSplash method always reports τ_b with the normal approximation.
- Statistic
- 282.000
- p-value
- 0.0215
Kendall τ test on 30 (x, y) pairs: T = 282, p = .021, τ = 0.30. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: Kendall population concordance τ=0; independence is the stronger permutation null.
Assumptions
Independent paired observations; ordinal scales. Use a tie adjusted variance for discrete observations.
Formula
Parameters and notation
C,D count concordant and discordant observation pairs; Tx,Ty count pairs tied only in X or only in Y.
Structure of the method
Count concordant and discordant pairs of observations, adjust normalization for one-variable ties, and standardize the concordance contrast under a specified exact or asymptotic reference. Tau-b and tau-c normalize effect sizes differently, while compatible test implementations may share the same null contrast.
Estimated and nuisance parameters
Concordance counts and tie-group sizes are observed summaries, and the population concordance coefficient is estimated. There are no fitted Gaussian means or scales. The exact no-tie distribution is determined by sample size and ordering, while tie-adjusted variance uses the observed tie structure.
Settings and design choices
Specify tau variant, alternative, continuity correction if relevant, and exact versus asymptotic p-value method. Python auto-selection and R exact=FALSE need not agree in small untied samples; explicit method settings are necessary for a controlled cross-language comparison.
Fitting and adaptation
Recompute pair orderings and tie groups when data change. A pairing-permutation calibration targets independence under exchangeability and must respect any blocking. Neural fine-tuning is irrelevant; adapting to ordinal categories means revisiting tie handling and the coefficient interpretation.
Sensitivity and robustness
Association in order is not agreement in measurement level. Extensive ties lower the attainable resolution and can create degenerate variance. Repeated observations or serial ordering require a different dependence-aware reference. Keep effect-size normalization separate from claims about p-value exactness.
How to use and calibrate
Use an exact distribution without ties when feasible, otherwise a tie corrected normal approximation or suitable permutation.
Example application
Evaluate ordinal agreement in ordering between two continuous or ranked measurements.
Interpretation and pitfalls
Watch out
Association is not absolute agreement; perfectly increasing scores may differ systematically in level.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
- Rewritten in the review: Python code.
Python codedocs.scipy.org
The original Python auto method may select exact inference for these ten untied observations, while the R example explicitly uses exact=FALSE. Both examples now explicitly demonstrate asymptotic calibration. This changed code was reviewed but not executed during the extension.
Corrected Python code
import numpy as np from scipy import stats rng = np.random.default_rng(2026) x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0]) y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9]) print(stats.kendalltau(x,y,method="asymptotic"))
Python and R
Paired observations, two-sided association test. Ties and exact-versus-asymptotic settings can cause small cross-language differences.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0])
y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9])
print(stats.kendalltau(x,y))
Output
SignificanceResult(statistic=np.float64(0.24444444444444444), pvalue=np.float64(0.38071979717813054))
Validated — Executed successfully in the validation environment · needs Base/standard library
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
print(cor.test(x,y,method="kendall",exact=FALSE))
Output
Kendall's rank correlation tau
data: x and y
z = 0.98387, p-value = 0.3252
alternative hypothesis: true tau is not equal to 0
sample estimates:
tau
0.2444444Sources
- SciPy — SciPy · kendalltaudocs.scipy.org
- scipy.stats.kendalltaudocs.scipy.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 079, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT079.