Kendall Rank Correlation

The Kendall Rank Correlation counts the pairs of periods in which two assets move in the same order (concordant) against those in which they move in opposite orders (discordant), the tau-b of Kendall (1938), corrected for ties.

The formula for the Kendall Rank Correlation starts from the number \(n_{0}\) of pairs of the T periods, with \(n_{c}\) the concordant and \(n_{d}\) the discordant pairs and \(n_{1}\) and \(n_{2}\) the pairs tied in the first and second asset; the distance \(d_{i , j}\) is the correlation distance:

\[n_{0} = \frac{T \cdot (T - 1)}{2}\] \[\tau_{i,j} = \frac{n_{c} - n_{d}}{\sqrt{(n_{0} - n_{1}) \cdot (n_{0} - n_{2})}}\] \[d_{i,j} = \sqrt{\frac{1 - \tau_{i,j}}{2}}\]

It reads as the probability of concordance minus that of discordance, so it tends to lie closer to zero than the Spearman Rank Correlation for the same returns, and an outlier changes it less than it changes the Pearson Correlation.

It is the codependence that the hierarchical optimizers (HRP, HERC, NCO) and get_asset_clusters take, or the distance they cluster on. Hierarchical portfolio construction groups the assets by how much they move together and spreads the capital across the groups, so the codependence decides which assets end up together. The Pearson correlation captures only linear co-movement on average; the other codependences capture co-movement in ranks, in large moves only, in any form of dependence or in crashes. Each comes with a distance, zero for assets that move as one, that the clustering works on (Mantegna, 1999).

Also known as: Kendall’s tau, tau-b.

In the Finance Toolkit this is get_codependence_matrix with method="kendall", the same function as Codependence Matrix.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_codependence_matrix:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_codependence_matrix(method="kendall")

Which returns:

References

  • Paper Kendall, M. G. (1938). “A New Measure of Rank Correlation.” Biometrika, 30(1-2), 81-93.
Share