UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.
Correlation Tests

Kendall’s Tau: Formula, Interpretation, Python, R, SPSS and Excel Guide

Rank correlation, ordinal data, concordant pairs, discordant pairs and tie correction Kendall’s Tau: Formula, Interpretation, Python, R, SPSS and Excel Guide Kendall’s Tau is a nonparametric...

Statistics guide Ethical learning support SPSS/R/Python/Excel friendly
Kendall’s Tau: Formula, Interpretation, Python, R, SPSS and Excel Guide

Rank correlation, ordinal data, concordant pairs, discordant pairs and tie correction

Kendall’s Tau: Formula, Interpretation, Python, R, SPSS and Excel Guide

Kendall’s Tau is a nonparametric rank correlation coefficient used to measure monotonic association between two ordered variables. It compares all observation pairs and checks whether they move in the same order or opposite order. This guide explains Kendall’s tau-b with Python charts, R charts, SPSS output, Excel formulas, concordant pairs, discordant pairs, tied ranks, p-values, matrix interpretation and APA reporting.

AdvertisementGoogle AdSense top placement reserved here

Quick Answer: Kendall’s Tau Result

The main analysis tested the monotonic association between G1 and G3. G1 is the first-period grade, and G3 is the final grade. Kendall’s tau-b was used because grade data contain many tied values.

The result was Kendall’s tau-b = 0.766198, with N = 649 complete pairs and p = 2.108694e-155. The direction is positive, the practical strength label is strong, and the decision is Reject H0: significant monotonic association.

X variableG1
Y variableG3
Complete pairs649
Methodtau-b

Kendall’s tau-b0.7662
p-value< .001
DirectionPositive
StrengthStrong

Final interpretation: Students with higher G1 ranks tend to have higher G3 ranks. The association is strong, positive and statistically significant. Because many grade values are tied, Kendall’s tau-b is the correct version to report.

Important rule: Kendall’s Tau measures ordered agreement, not necessarily a straight-line relationship. Use it when the relationship is monotonic and when ordinal ranks or tied values make Pearson correlation less ideal.

Table of Contents

  1. What Is Kendall’s Tau?
  2. Kendall’s Tau Formula
  3. Null and Alternative Hypotheses
  4. Dataset and Variables Used
  5. Verified Kendall’s Tau Results
  6. Python Chart-by-Chart Interpretation
  7. R Chart-by-Chart Interpretation
  8. SPSS Output Interpretation
  9. Excel Worked File Explanation
  10. Python, R, SPSS and Excel Workflows
  11. Code Blocks and Excel Formulas
  12. How to Report Kendall’s Tau
  13. Common Mistakes
  14. Downloads and Resources
  15. Related Statistical Guides
  16. FAQs About Kendall’s Tau

What Is Kendall’s Tau?

Kendall’s Tau is a rank-based measure of association between two variables. Instead of using raw distances between values, it studies the ordering of observations. If higher values of one variable usually match higher values of the other variable, tau is positive. If higher values of one variable usually match lower values of the other variable, tau is negative.

Kendall’s Tau is useful for ordinal data, ranked data, non-normal data and data with many repeated values. In this guide, G1 and G3 are numeric grade variables, but the repeated grade values create many ties. That is why Kendall’s tau-b is used instead of a tie-free tau-a version.

Kendall’s Tau is related to Correlation in Python, Correlation in R, Correlation Matrix, Correlation Assumptions, p-value, effect size and descriptive statistics explained.

Simple definition: Kendall’s Tau measures how often paired observations are ordered in the same direction compared with the opposite direction.

Kendall’s Tau Formula

The simple tie-free Kendall tau idea is:

τ = (C − D) / [n(n − 1) / 2]

Here, C is the number of concordant pairs, D is the number of discordant pairs, and n(n − 1) / 2 is the total number of observation pairs.

Because real datasets often contain ties, Kendall’s tau-b uses a tie-corrected denominator:

τb = (C − D) / √[(C + D + Tx)(C + D + Ty)]
SymbolMeaningValue in G1 vs G3 Example
CConcordant pairs158,466
DDiscordant pairs13,791
TxTies in X only16,516
TyTies in Y only16,614
Ties on bothPairs tied on both variables4,889
τbKendall’s tau-b0.766198

The large number of concordant pairs compared with discordant pairs explains why the coefficient is strongly positive.

Null and Alternative Hypotheses

The Kendall’s Tau hypothesis test checks whether the population rank association is zero.

StatementHypothesisMeaning
Null hypothesisH0: Kendall’s tau-b = 0There is no monotonic association between G1 and G3.
Alternative hypothesisH1: Kendall’s tau-b ≠ 0A monotonic association exists between G1 and G3.
Decision ruleReject H0 if p < .05The observed rank association is statistically significant.

Decision: Because p = 2.108694e-155 is far below .05, the null hypothesis is rejected. There is a statistically significant positive monotonic association between G1 and G3.

Dataset and Variables Used

The analysis used the student performance dataset. The main variables were G1 and G3. A wider Kendall’s tau-b matrix also included age, Medu, Fedu, traveltime, studytime, failures, famrel, freetime, goout, Dalc, Walc, health, absences, G1, G2 and G3.

VariableRoleScale TypeReason for Kendall’s Tau
G1Primary X variableNumeric gradeRanked first-period grade score.
G3Primary Y variableNumeric gradeRanked final grade score.
G2Additional grade variableNumeric gradeIncluded in top pairwise matrix.
failuresAcademic risk variableOrdinal/count-likeShows negative rank association with grades.
Medu and FeduParent education variablesOrdinalGood example of ordinal Kendall correlation.

Before interpreting Kendall’s Tau, check whether the variables are ordered, whether rows are independent, whether the relationship is monotonic, and whether ties are present. In this dataset, ties are common, so tau-b is the appropriate version.

Verified Kendall’s Tau Results

The main result and top pairwise results are shown below. Pairs are ranked by absolute tau-b strength.

RankPairNKendall’s tau-bp-valueDirectionInterpretation
1G2 vs G36490.8695952.113285e-199PositiveVery strong ordered grade association.
2G1 vs G26490.7806394.403489e-161PositiveStrong ordered grade association.
3G1 vs G36490.7661982.108694e-155PositiveMain result; strong monotonic association.
4Medu vs Fedu6490.5699545.622318e-68PositiveModerate-to-strong parent education association.
5Dalc vs Walc6490.5554074.096093e-59PositiveWeekday and weekend alcohol use are ordered together.
6failures vs G3649-0.3788832.182742e-30NegativeHigher failures are associated with lower final grade ranks.
7failures vs G2649-0.3679699.916502e-29NegativeHigher failures are associated with lower G2 ranks.
8failures vs G1649-0.3657801.963360e-28NegativeHigher failures are associated with lower G1 ranks.
9goout vs Walc6490.3149071.732229e-22PositiveGoing out and weekend alcohol use move together.
10freetime vs goout6490.3039046.841912e-21PositiveFree time and going out are positively ordered.

The strongest overall pair is G2 vs G3, while the primary teaching example is G1 vs G3. The failures variable has the strongest negative grade relationships.

AdvertisementGoogle AdSense middle placement reserved here

Python Chart-by-Chart Interpretation

The Python report includes six charts: rank scatterplot, pair classification counts, Kendall matrix heatmap, p-value heatmap, top tau pairs and primary variable distributions.

Python Chart 1: Kendall’s Tau Rank Scatterplot

Python Kendall's Tau rank scatterplot for G1 and G3
Python rank scatterplot showing the monotonic relationship between G1 and G3 ranks.

The rank scatterplot shows that higher G1 ranks generally align with higher G3 ranks. The pattern is upward and monotonic, which supports the positive Kendall’s tau-b value of 0.766198.

This chart is useful because Kendall’s Tau is a rank-based method. The chart does not require a perfect straight line; it only needs a consistent ordered pattern. The strong upward rank pattern supports the final conclusion.

Python Chart 2: Pair Classification Counts

Python pair classification counts for Kendall's Tau
Python chart showing concordant, discordant and tied observation-pair counts.

This chart explains the tau-b calculation directly. The analysis found 158,466 concordant pairs and 13,791 discordant pairs. Concordant pairs dominate the result, which is why tau-b is strongly positive.

The chart also shows ties in X only, ties in Y only and ties on both variables. These ties are expected because grade scores repeat across many students. Kendall’s tau-b corrects for those ties.

Python Chart 3: Kendall’s Tau Matrix Heatmap

Python Kendall's Tau matrix heatmap
Python heatmap showing tau-b values among numeric and ordinal variables.

The matrix heatmap shows ordered associations across all selected numeric and ordinal variables. The grade block stands out clearly: G1, G2 and G3 have strong positive tau-b relationships.

The heatmap also shows meaningful negative grade relationships involving failures. This means students with more previous failures tend to have lower ordered grade positions.

Python Chart 4: Kendall’s Tau p-value Heatmap

Python Kendall's Tau p-value heatmap
Python p-value heatmap for pairwise Kendall’s tau-b tests.

The p-value heatmap separates statistical evidence from practical strength. Strong grade relationships have extremely small p-values. Some weaker associations may also be significant because the sample size is large.

This chart should be interpreted together with the tau-b matrix. The tau-b value tells strength and direction, while the p-value tells whether the association is statistically detectable.

Python Chart 5: Top Kendall’s Tau Pairs

Python top Kendall's Tau pairs chart
Python chart ranking the strongest Kendall’s tau-b relationships.

The top-pairs chart ranks relationships by absolute tau-b value. The strongest pair is G2 vs G3, followed by G1 vs G2 and G1 vs G3. This shows that the grade variables form the strongest ordered cluster.

Negative relationships involving failures also appear in the ranking. These should be described as negative monotonic relationships, not causal effects.

Python Chart 6: Primary Variable Distributions

Python primary variable distributions for G1 and G3
Python chart showing distributions of G1 and G3.

The distribution chart shows that G1 and G3 contain repeated grade values. These repeated values create tied ranks. Because ties are present, tau-b is better than tau-a.

This chart supports the method choice. Kendall’s tau-b is designed for ordered data with ties, making it appropriate for grade variables with repeated scores.

R Chart-by-Chart Interpretation

The R report validates the same result using a separate workflow. It includes colorful charts for rank scatterplot, pair classification counts, tau matrix, top tau pairs and primary variable distributions.

R Chart 1: Colorful Kendall’s Tau Rank Scatterplot

R colorful Kendall's Tau rank scatterplot
R rank scatterplot showing the positive monotonic association between G1 and G3.

The R rank scatterplot confirms the same upward ordered pattern. Higher G1 ranks generally match higher G3 ranks. This visual pattern agrees with tau-b = 0.766198.

R Chart 2: Colorful Pair Classification Counts

R colorful pair classification counts for Kendall's Tau
R chart showing concordant, discordant and tied pair counts.

The R pair-count chart confirms that concordant pairs are far more common than discordant pairs. This explains the strong positive coefficient. The tie categories again show why tau-b is reported.

R Chart 3: Colorful Kendall’s Tau Matrix Heatmap

R colorful Kendall's Tau matrix heatmap
R matrix heatmap showing pairwise Kendall’s tau-b values.

The R tau matrix confirms the same strongest ordered relationships. The G1, G2 and G3 block is strongly positive, while failures have negative relationships with grade variables.

R Chart 4: Colorful Top Kendall’s Tau Pairs

R colorful top Kendall's Tau pairs chart
R chart ranking the strongest pairwise Kendall’s tau-b results.

The top-pairs chart confirms the ranking: G2 vs G3 is strongest, G1 vs G2 is second, and G1 vs G3 is third. The repeated agreement across Python, R and Excel strengthens the result.

R Chart 5: Colorful Primary Variable Distributions

R colorful primary variable distributions for Kendall's Tau
R chart showing the distributions of G1 and G3.

The R distribution chart again shows many tied values in G1 and G3. This supports the choice of Kendall’s tau-b and helps explain why tie correction is required.

SPSS Output Interpretation

The SPSS output confirms the primary nonparametric correlation between G1 and G3. SPSS reports Kendall’s tau-b correlation coefficient of approximately .766, Sig. (2-tailed) = .000, and N = 649.

Open the SPSS Kendall’s Tau Output PDF

SPSS Output ItemValueInterpretation
Primary pairG1 and G3First-period grade compared with final grade.
Kendall’s tau-b.766Strong positive monotonic association.
Sig. (2-tailed).000Statistically significant at the .01 level.
N649Complete valid pair count.
DecisionReject H0There is significant monotonic association.

The SPSS result is shorter than the Python and R reports, but it gives the formal nonparametric correlation table many students need for assignments, theses and research reports.

Excel Worked File Explanation

The Excel workbook gives a fully worked Kendall’s Tau analysis. It includes the original dataset, primary G1 and G3 data, a first-30-observation pairwise demo, a full Kendall matrix, top pairwise results and an assumptions sheet.

Download the Kendall’s Tau Fully Worked Excel File

Excel SheetPurposeMain Content
DashboardQuick result summary.Shows G1 vs G3 tau-b, p-value, decision and top pairs.
DatasetOriginal uploaded dataset.All variables used for the correlation matrix.
Primary_DataMain G1 and G3 calculation area.Ranks, complete n and Kendall’s tau-b summary.
Pairwise_Demo_30Manual pair classification demo.Shows concordant, discordant and tied pair formulas for first 30 rows.
Kendall_MatrixFull pairwise tau-b matrix.Pairwise tau-b values across numeric and ordinal variables.
Top_PairsRanked pairwise results.Top relationships sorted by absolute tau-b.
AssumptionsReporting and assumption guide.Scale, independence, monotonicity, ties and missing-value rules.

The Excel dashboard confirms the primary result: Kendall’s tau-b = 0.7661978205, p = 2.1086936598e-155, and decision Reject H0: significant monotonic association. The pairwise demo also shows how pair classification works for the first 30 observations.

Pairwise Demo ItemFirst 30 Observation ValueMeaning
Demo pairs435Total i < j observation pairs for first 30 rows.
Concordant pairs291Pairs ordered in the same direction.
Discordant pairs26Pairs ordered in opposite directions.
X ties only49Pairs tied only on G1.
Y ties only51Pairs tied only on G3.
Ties on both18Pairs tied on both G1 and G3.
Demo tau-b0.7221Manual tau-b formula applied to the demo rows.

This workbook is especially useful for teaching because it shows the logic behind the coefficient instead of only presenting the final value.

AdvertisementGoogle AdSense in-content placement reserved here

Python, R, SPSS and Excel Workflows

SoftwareMain WorkflowBest Use
PythonUse pandas for data handling, scipy.stats.kendalltau for tau-b and matplotlib for rank/pair charts.Automated analysis, charts and matrix reporting.
RUse cor.test(method = “kendall”, exact = FALSE), matrix calculations and R graphics.Statistical validation and colorful publication charts.
SPSSUse Nonparametric Correlations with Kendall’s tau-b selected.Formal output table and thesis-style reporting.
ExcelUse rank formulas, pair classification, COUNT/SUM formulas and tau-b denominator calculation.Manual learning and formula-based checking.

Code Blocks and Excel Formulas

Python Code for Kendall’s Tau

import pandas as pd
from scipy.stats import kendalltau

df = pd.read_csv("dataset.csv")

x_var = "G1"
y_var = "G3"

work = df[[x_var, y_var]].dropna()
tau, p_value = kendalltau(work[x_var], work[y_var])

print("Complete pairs:", len(work))
print("Kendall tau-b:", tau)
print("Two-tailed p-value:", p_value)

if p_value < 0.05:
    print("Reject H0: significant monotonic association")
else:
    print("Fail to reject H0")

Python Code for Pair Classification

import numpy as np

x = work[x_var].to_numpy()
y = work[y_var].to_numpy()

C = D = Tx = Ty = Tboth = 0

for i in range(len(x)):
    for j in range(i + 1, len(x)):
        dx = np.sign(x[j] - x[i])
        dy = np.sign(y[j] - y[i])

        if dx == 0 and dy == 0:
            Tboth += 1
        elif dx == 0:
            Tx += 1
        elif dy == 0:
            Ty += 1
        elif dx == dy:
            C += 1
        else:
            D += 1

tau_b_manual = (C - D) / np.sqrt((C + D + Tx) * (C + D + Ty))

print("Concordant:", C)
print("Discordant:", D)
print("X ties only:", Tx)
print("Y ties only:", Ty)
print("Ties on both:", Tboth)
print("Manual tau-b:", tau_b_manual)

R Code for Kendall's Tau

df <- read.csv("dataset.csv", stringsAsFactors = FALSE)

x_var <- "G1"
y_var <- "G3"

work <- na.omit(df[, c(x_var, y_var)])

test <- cor.test(
  work[[x_var]],
  work[[y_var]],
  method = "kendall",
  exact = FALSE
)

print(test)

cat("Complete pairs:", nrow(work), "\n")
cat("Kendall tau-b:", unname(test$estimate), "\n")
cat("p-value:", test$p.value, "\n")

SPSS Syntax for Kendall's Tau

* Kendall's Tau in SPSS.
OUTPUT CLOSE ALL.
OUTPUT NEW NAME=Kendalls_Tau_Output.

DESCRIPTIVES VARIABLES=G1 G3
  /STATISTICS=MEAN STDDEV MIN MAX.

NONPAR CORR
  /VARIABLES=G1 G3
  /PRINT=KENDALL TWOTAIL
  /MISSING=PAIRWISE.

NONPAR CORR
  /VARIABLES=age Medu Fedu traveltime studytime failures famrel freetime goout Dalc Walc health absences G1 G2 G3
  /PRINT=KENDALL TWOTAIL
  /MISSING=PAIRWISE.

OUTPUT EXPORT
  /CONTENTS EXPORT=VISIBLE
  /PDF DOCUMENTFILE='Kendalls-Tau-SPSS-Output.pdf'.

Excel Formula Patterns for Kendall's Tau

For each observation pair i < j:

Difference in X:
=X_j-X_i

Difference in Y:
=Y_j-Y_i

Sign of X difference:
=SIGN(X_j-X_i)

Sign of Y difference:
=SIGN(Y_j-Y_i)

Pair class:
=IF(AND(sign_dx=0,sign_dy=0),"Both tied",
 IF(sign_dx=0,"Tie X only",
 IF(sign_dy=0,"Tie Y only",
 IF(sign_dx=sign_dy,"Concordant","Discordant"))))

Concordant count:
=COUNTIF(pair_class_range,"Concordant")

Discordant count:
=COUNTIF(pair_class_range,"Discordant")

X ties only:
=COUNTIF(pair_class_range,"Tie X only")

Y ties only:
=COUNTIF(pair_class_range,"Tie Y only")

Kendall tau-b:
=(C-D)/SQRT((C+D+Tx)*(C+D+Ty))

How to Report Kendall's Tau

A good Kendall's Tau report should name the variables, sample size, tau-b value, p-value, direction, practical strength and tie handling.

APA-style report: Kendall's tau-b was calculated to examine the monotonic association between G1 and G3. The analysis included 649 complete pairs. There was a strong positive monotonic association between G1 and G3, τb = .766, p < .001. The null hypothesis of no monotonic association was rejected. Because many tied grade values were present, Kendall's tau-b was reported.

Expanded report: The G1 and G3 pair produced 210,276 total observation pairs, including 158,466 concordant pairs and 13,791 discordant pairs. The large excess of concordant over discordant pairs produced a strong positive Kendall's tau-b coefficient of .766.

Common Mistakes in Kendall's Tau Interpretation

MistakeWhy It Is a ProblemBetter Practice
Calling Kendall's Tau a linear correlationKendall's Tau measures ordered monotonic association, not linear slope.Use monotonic association wording.
Ignoring tiesGrade and ordinal data often contain tied values.Report Kendall's tau-b when ties are present.
Reporting only p-valuep-value does not show strength.Report tau-b value and practical interpretation.
Using Pearson correlation for ordinal dataOrdinal spacing may not be equal.Use Kendall's Tau or Spearman correlation for ranked/ordinal data.
Ignoring monotonicityTau is not meant to detect every complex pattern.Check rank scatterplots and distribution charts.
Assuming causationCorrelation does not prove cause and effect.Use association wording unless research design supports causality.

Downloads and Resources

External References

For software documentation, see SciPy documentation for kendalltau, R documentation for cor.test, IBM SPSS documentation for nonparametric correlations and Microsoft Excel documentation for ranking and COUNT formulas.

FAQs About Kendall's Tau

What is Kendall's Tau?

Kendall's Tau is a nonparametric rank correlation coefficient. It measures monotonic association by comparing concordant and discordant observation pairs.

What was the Kendall's Tau result in this guide?

The main result was Kendall's tau-b = 0.766198 for G1 and G3, with N = 649 and p < .001. This is a strong positive monotonic association.

What is the difference between tau-a and tau-b?

Tau-a does not correct for ties. Tau-b corrects for ties in the two variables. Because grade data contain many repeated values, tau-b is the correct version here.

Is Kendall's Tau the same as Spearman correlation?

No. Both are rank-based, but Kendall's Tau is based on concordant and discordant pair counts, while Spearman correlation is Pearson correlation applied to ranks.

Can SPSS calculate Kendall's Tau?

Yes. In SPSS, use Nonparametric Correlations and select Kendall's tau-b. The SPSS output reports the coefficient, two-tailed significance and N.

Can Excel calculate Kendall's Tau?

Yes, but it requires manual pair classification formulas or a prepared workbook. The downloadable Excel file in this guide shows the full calculation.

AdvertisementGoogle AdSense bottom placement reserved here

Need help applying this to your own data?

Salar Cafe can help interpret output, clean datasets, review assumptions, build dashboards and explain statistical results ethically.

Need help interpreting your data analysis results?

Contact Salar Cafe
Engr. Muhammad Yar Saqib author profile photo

Engr. Muhammad Yar Saqib

WhatsApp Get Data Analysis Help