Kendall's tau - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To measure the strength of relationship between 2 variables.

Null hypothesis: Correlation coefficient = 0

Alternate hypothesis: Correlation coefficient ≠ 0.

Note: Kendall's tau is a correlation measure for ordinal data; hence, a non-parametric measure. Values close to 1 indicate strong agreement, and values close to -1 indicate strong disagreement.

Code:

>>> from scipy import stats
>>> X = [1, 2, 3, 4, 5]
>>> Y = [5, 6, 7, 8, 7]
>>> result = stats.kendalltau(X, Y)
>>> print("Kendall's tau = %.3f" % result.correlation)
Kendall's tau = 0.738
>>> print("p-value = %.3f" % result.pvalue)
p-value = 0.077

Reference

  1. Kendall MG. 1938. A New Measure of Rank Correlation. Biometrika 30(1/2), 81-93.
  2. Kendall MG. 1945. The treatment of ties in ranking problems. Biometrika 33(3), 239-251.