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-b: Formula, Interpretation, Python, R, SPSS and Excel Guide

Tie-corrected rank correlation, ordinal association and monotonic relationship testing Kendall’s Tau-b: Formula, Interpretation, Python, R, SPSS and Excel Guide Kendall’s Tau-b is a nonparametric rank correlation...

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

Tie-corrected rank correlation, ordinal association and monotonic relationship testing

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

Kendall’s Tau-b is a nonparametric rank correlation coefficient that measures monotonic association while correcting for tied ranks. It is especially useful for ordinal variables, grade data, Likert-type responses, non-normal data and datasets where repeated values are common. This guide explains the tau-b formula, concordant pairs, discordant pairs, tie correction, Python charts, R charts, SPSS output, Excel formulas and APA reporting.

AdvertisementGoogle AdSense top placement reserved here

Quick Answer: Kendall’s Tau-b Result

The worked and strongest pair in this analysis is G2 vs G3. G2 is the second-period grade and G3 is the final grade. Kendall’s tau-b was selected because the grade variables have repeated values, meaning ties are common.

The result is Kendall’s tau-b = 0.869595, with N = 649 valid paired observations and p = 2.113285e-199. This is a very strong positive monotonic association. The null hypothesis of no monotonic association is rejected.

Worked pairG2 vs G3
Valid N649
MethodTau-b
DecisionSignificant

Kendall’s tau-b0.8696
p-value< .001
DirectionPositive
StrengthVery strong

Final interpretation: Students with higher G2 ranks tend to have higher G3 ranks. The relationship is very strong, positive and statistically significant. Because repeated grade values create tied ranks, Kendall’s tau-b is the correct coefficient to report.

Important distinction: Kendall’s tau-b is not the same as Pearson correlation. Pearson focuses on linear association using raw values, while Kendall’s tau-b focuses on ordered agreement between pairs and corrects for tied ranks.

Table of Contents

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

What Is Kendall’s Tau-b?

Kendall’s Tau-b is a rank-based correlation coefficient used to measure monotonic association between two variables while correcting for ties. A monotonic association means that as one variable increases, the other variable tends to increase or decrease consistently, even if the pattern is not perfectly linear.

Tau-b compares every pair of observations. If the order of two observations is the same on both variables, the pair is concordant. If the order is opposite, the pair is discordant. If one or both variables have equal values for the pair, ties are counted and corrected in the denominator.

Kendall’s Tau-b is closely related to Correlation in Python, Correlation in R, Correlation in SPSS, Correlation in Excel, Correlation Matrix, Correlation Assumptions, p-value, effect size and parametric vs nonparametric tests.

Simple definition: Kendall’s tau-b measures whether two variables have the same rank order more often than the opposite rank order, while adjusting for tied values.

Kendall’s Tau-a vs Tau-b vs Spearman

Students often confuse Kendall’s tau-a, Kendall’s tau-b and Spearman correlation. They are all rank-based ideas, but they do not handle ties in the same way.

MeasureBest UseTie HandlingExample
Kendall’s tau-aRank data with no ties.Does not correct for ties.Unique competition ranks from 1 to n.
Kendall’s tau-bOrdinal or numeric data with ties.Corrects for ties in X and Y.G2 and G3 grade scores with repeated values.
Spearman correlationRanked or monotonic data.Uses ranked values and average ranks for ties.Checking a monotonic relationship using rank-transformed data.
Pearson correlationContinuous variables with linear association.Not a rank method.Linear correlation between two normally distributed variables.

Best choice here: Since G2 and G3 contain many repeated grade values, tau-b is more appropriate than tau-a.

Kendall’s Tau-b Formula

The tie-corrected Kendall’s tau-b formula is:

τb = (C − D) / √[(C + D + Tx)(C + D + Ty)]

In this formula, C is the number of concordant pairs, D is the number of discordant pairs, Tx is the number of pairs tied only on X, and Ty is the number of pairs tied only on Y.

Formula ElementMeaningG2 vs G3 Value
CConcordant pairs169,536
DDiscordant pairs5,460
TxPairs tied only on G213,777
TyPairs tied only on G313,593
Both tiesPairs tied on both G2 and G37,910
Total pairsn(n − 1) / 2210,276
τbKendall’s tau-b0.869595

The result is strongly positive because concordant pairs greatly outnumber discordant pairs. The tie correction is necessary because grade values repeat often.

Null and Alternative Hypotheses

Kendall’s tau-b tests whether the population monotonic rank association is zero.

StatementHypothesisMeaning
Null hypothesisH0: τb = 0There is no monotonic association between G2 and G3.
Alternative hypothesisH1: τb ≠ 0There is a monotonic association between G2 and G3.
Decision ruleReject H0 if p < .05The rank association is statistically significant.

Decision: Since p = 2.113285e-199 is far below .05, the null hypothesis is rejected. There is a statistically significant very strong positive monotonic association between G2 and G3.

Dataset and Variables Used

The analysis used 16 numeric or ordinal variables from the student performance dataset. The strongest worked pair was G2 vs G3. The matrix also included age, Medu, Fedu, traveltime, studytime, failures, famrel, freetime, goout, Dalc, Walc, health, absences, G1, G2 and G3.

VariableRoleScale TypeReason for Tau-b
G2Worked X variableNumeric grade with tiesSecond-period grade; strongest pair with G3.
G3Worked Y variableNumeric grade with tiesFinal grade; strongly ordered with G2.
G1Additional grade variableNumeric grade with tiesStrongly associated with G2 and G3.
Medu and FeduParent education variablesOrdinalGood examples of ordered categorical variables.
Dalc and WalcAlcohol-use variablesOrdinalShow strong ordinal association with ties.
failuresAcademic risk variableOrdinal/count-likeNegatively associated with grade variables.

The diagnostic table shows that all 16 variables had N = 649 valid values and no missing values. Several ordinal-style variables had large tie groups, such as failures, Dalc, traveltime and studytime. This supports the use of Kendall’s tau-b instead of a tie-free rank correlation.

Verified Kendall’s Tau-b Results

The strongest association is G2 vs G3, followed by G1 vs G2 and G1 vs G3. The grade variables form the strongest positive rank-correlation block in the matrix.

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

The practical conclusion is that grade variables have the strongest positive monotonic relationships, while failures has the strongest negative relationship with grades.

AdvertisementGoogle AdSense middle placement reserved here

Python Chart-by-Chart Interpretation

The Python report includes six charts: tau-b heatmap, p-value heatmap, top tau-b pairs, worked pair jittered scatterplot, tie profile and concordant-discordant-tie counts.

Python Chart 1: Kendall’s Tau-b Heatmap

Python Kendall's Tau-b heatmap
Python heatmap showing Kendall’s tau-b values across the selected variables.

The tau-b heatmap shows the direction and strength of monotonic association across the full variable set. Positive cells indicate that higher ranks on one variable tend to match higher ranks on the other variable. Negative cells indicate that higher ranks on one variable tend to match lower ranks on the other variable.

The strongest positive block appears among the grade variables G1, G2 and G3. The strongest negative pattern appears between failures and the grade variables. This visual summary supports the ranked top-pair table.

Python Chart 2: Kendall’s Tau-b p-value Heatmap

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

The p-value heatmap shows where the statistical evidence is strongest. The grade relationships have extremely small p-values, especially G2 vs G3, G1 vs G2 and G1 vs G3.

This chart should be read alongside the tau-b heatmap. The tau-b heatmap gives strength and direction, while the p-value heatmap gives statistical evidence. A small p-value does not automatically mean a strong effect, so both charts are necessary.

Python Chart 3: Top Kendall’s Tau-b Pairs

Python top Kendall's Tau-b pairs chart
Python chart ranking the strongest Kendall’s tau-b associations by absolute coefficient size.

The top-pairs chart clearly ranks the strongest monotonic relationships. G2 vs G3 is the strongest with tau-b about 0.8696. G1 vs G2 and G1 vs G3 follow closely, showing that the grade measurements are highly ordered together.

The failures pairs are negative, meaning students with more past failures tend to rank lower on grade outcomes. This should be reported as association, not causation.

Python Chart 4: Worked Pair Jittered Scatterplot

Python worked pair jittered scatterplot for Kendall's Tau-b G2 and G3
Python jittered scatterplot for the worked pair G2 vs G3.

The jittered scatterplot shows the relationship between G2 and G3. Because grades are repeated integer values, many points would overlap without jittering. Jitter makes the dense tied values easier to see while preserving the overall pattern.

The upward pattern is very clear: higher G2 values are strongly associated with higher G3 values. This matches the very high tau-b value of 0.8696.

Python Chart 5: Tie Profile

Python tie profile chart for Kendall's Tau-b
Python tie profile showing largest repeated-value groups by variable.

The tie profile explains why Kendall’s tau-b is needed. Some variables have very large tie groups. For example, failures has many observations at zero, Dalc has many observations at one, and several ordinal variables have repeated category values.

When ties are common, tau-b is preferred because it adjusts the denominator for ties in each variable. Without tie correction, the coefficient can be misleading.

Python Chart 6: Concordant, Discordant and Tie Counts

Python concordant discordant tie counts chart for Kendall's Tau-b
Python chart showing concordant, discordant, X-only ties, Y-only ties and both-variable ties for the worked pair.

This chart directly explains the formula. For G2 vs G3, there are 169,536 concordant pairs and only 5,460 discordant pairs. This large excess of concordant pairs produces the strong positive tau-b value.

The chart also shows X-only ties, Y-only ties and both-variable ties. These tied values are part of the reason tau-b is used instead of tau-a.

R Chart-by-Chart Interpretation

The R report validates the Python results using colorful charts. The same six ideas are repeated: tau-b heatmap, p-value heatmap, top pairs, worked scatterplot, tie profile and pair classification counts.

R Chart 1: Colorful Kendall’s Tau-b Heatmap

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

The R heatmap confirms the same pattern: grade variables form the strongest positive cluster, while failures has negative associations with G1, G2 and G3. This confirms that the Python heatmap is not a software-specific result.

R Chart 2: Colorful Kendall’s Tau-b p-value Heatmap

R colorful Kendall's Tau-b p-value heatmap
R p-value heatmap showing evidence for monotonic association.

The R p-value heatmap confirms the extremely small p-values for the strongest grade relationships. G2 vs G3, G1 vs G2 and G1 vs G3 show very strong statistical evidence of monotonic association.

R Chart 3: Colorful Top Kendall’s Tau-b Pairs

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

The R top-pairs chart confirms that G2 vs G3 is the strongest pair, followed by G1 vs G2 and G1 vs G3. The same ordering appears in the Python report and Excel workbook.

R Chart 4: Colorful Worked Pair Jittered Scatterplot

R colorful worked pair scatterplot for Kendall's Tau-b
R jittered scatterplot for the worked pair G2 vs G3.

The R scatterplot again shows a strong upward monotonic pattern between G2 and G3. Jittering helps reveal repeated grade combinations where many points overlap.

R Chart 5: Colorful Tie Profile

R colorful tie profile chart for Kendall's Tau-b
R tie profile showing the largest repeated-value groups.

The R tie profile reinforces the methodological choice. Variables with repeated categories or repeated grade values need tie correction. Kendall’s tau-b handles this directly.

R Chart 6: Colorful Concordant, Discordant and Tie Counts

R colorful concordant discordant tie counts chart for Kendall's Tau-b
R chart showing pair classification counts for the worked pair.

The R pair-classification chart confirms the formula logic: concordant pairs dominate discordant pairs. That is why the final coefficient is strongly positive.

SPSS Output Interpretation

The SPSS output provides a formal Kendall’s tau-b correlation matrix. SPSS confirms the strongest grade relationships, including G2 with G3, G1 with G2 and G1 with G3.

Open the SPSS Kendall’s Tau-b Output PDF

SPSS Output ItemValueInterpretation
Primary strongest pairG2 with G3Second-period grade and final grade.
Kendall’s tau-b.870Very strong positive monotonic association.
Sig. (2-tailed).000Statistically significant at .01 level.
N649Complete valid paired observations.
G1 with G2.781Strong positive monotonic association.
G1 with G3.766Strong positive monotonic association.

The SPSS result should be reported with rounded values. For example, G2 and G3 showed a very strong positive monotonic relationship, τb = .870, p < .001, N = 649.

Excel Worked File Explanation

The Excel workbook is a fully worked Kendall’s tau-b analysis. It includes a report sheet, raw data, numeric data, variable diagnostics, pairwise tau-b table, tau-b matrix, p-value matrix, top-pairs table and worked formula example.

Download the Kendall’s Tau-b Fully Worked Excel File

Excel SheetPurposeMain Content
ReportQuick result summary.Shows strongest pair, top 10 associations, assumptions and reporting sentence.
Raw_DataOriginal dataset.Full uploaded student performance dataset.
Numeric_DataNumeric and ordinal variables.16 variables used in the tau-b matrix.
Variable_DiagnosticsTie and scale checks.Valid N, missing values, unique values, largest tie group and measurement notes.
Pairwise_Tau_bAll pairwise tau-b tests.120 pairwise tests with coefficient, p-value and decision.
Tau_b_MatrixCoefficient matrix.Matrix layout of tau-b values.
P_Value_MatrixSignificance matrix.Pairwise two-tailed p-values.
Top_PairsRanked strongest associations.Top tau-b pairs sorted by absolute coefficient.
Worked_ExampleManual formula demonstration.Concordant, discordant and tied pair counts for G2 vs G3.

The workbook’s worked example uses G2 vs G3. It calculates 169,536 concordant pairs, 5,460 discordant pairs, 13,777 G2-only ties, 13,593 G3-only ties and 7,910 ties on both variables. These values produce Kendall’s tau-b = 0.8695948161.

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 heatmaps, tie profiles and pair-count charts.Automated charts, matrices and reproducible reports.
RUse cor.test(method = “kendall”, exact = FALSE), pairwise loops and ggplot-style charts.Statistical validation and colorful chart output.
SPSSUse Nonparametric Correlations with Kendall’s tau-b selected.Formal correlation matrix and thesis/report output.
ExcelUse rank logic, pair classification formulas, COUNTIF, SQRT and manual tau-b formula.Formula learning and transparent manual calculation.

Code Blocks and Excel Formulas

Python Code for Kendall’s Tau-b

import pandas as pd
from scipy.stats import kendalltau

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

x_var = "G2"
y_var = "G3"

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

tau_b, p_value = kendalltau(work[x_var], work[y_var])

print("Complete pairs:", len(work))
print("Kendall's tau-b:", tau_b)
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 Concordant, Discordant and Tie Counts

import numpy as np

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

C = 0
D = 0
Tx = 0
Ty = 0
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 pairs:", C)
print("Discordant pairs:", D)
print("X-only ties:", Tx)
print("Y-only ties:", Ty)
print("Both ties:", Tboth)
print("Manual Kendall's tau-b:", tau_b_manual)

R Code for Kendall's Tau-b

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

x_var <- "G2"
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
)

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

print(test)

SPSS Syntax for Kendall's Tau-b

* Kendall's Tau-b in SPSS.
OUTPUT CLOSE ALL.
OUTPUT NEW NAME=Kendalls_Tau_b_Output.

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

NONPAR CORR
  /VARIABLES=G2 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-b-SPSS-Output.pdf'.

Excel Formula Patterns for Kendall's Tau-b

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 pairs:
=COUNTIF(pair_class_range,"Concordant")

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

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

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

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

Decision:
=IF(p_value<0.05,"Significant monotonic association","Not significant")

How to Report Kendall's Tau-b

A complete Kendall's tau-b report should include the variables, sample size, coefficient, p-value, direction, strength and tie handling.

APA-style report: Kendall's tau-b was calculated to examine the monotonic association between G2 and G3. The analysis included 649 complete paired observations. There was a very strong positive monotonic association between G2 and G3, τb = .870, p < .001. The null hypothesis of no monotonic association was rejected. Because the grade variables contained tied values, Kendall's tau-b was reported.

Expanded interpretation: The G2 and G3 worked pair produced 210,276 observation pairs, including 169,536 concordant pairs and 5,460 discordant pairs. Concordant pairs greatly outnumbered discordant pairs, producing a very strong positive tau-b coefficient of .870.

Common Mistakes in Kendall's Tau-b Interpretation

MistakeWhy It Is a ProblemBetter Practice
Using tau-a when ties existTau-a does not correct for tied ranks.Use tau-b for grade, Likert or ordinal data with repeated values.
Calling tau-b a linear correlationTau-b measures monotonic rank association, not linear slope.Use monotonic association wording.
Reporting only p-valuep-value does not show practical strength.Report tau-b coefficient and p-value together.
Ignoring directionPositive and negative tau-b values have different meanings.State whether higher ranks move together or in opposite directions.
Forgetting tie profileTies explain why tau-b is selected.Mention tied ranks when reporting tau-b.
Claiming causationCorrelation does not prove cause and effect.Use association wording unless the study design supports causal claims.

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 COUNTIF and SQRT formulas.

FAQs About Kendall's Tau-b

What is Kendall's Tau-b?

Kendall's Tau-b is a nonparametric rank correlation coefficient that measures monotonic association while correcting for tied ranks.

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

The strongest worked pair was G2 vs G3 with Kendall's tau-b = 0.869595, N = 649 and p < .001. This indicates a very strong positive monotonic association.

Why use tau-b instead of tau-a?

Tau-b corrects for ties in both variables. Since grade variables have repeated values, tau-b is more appropriate than tau-a.

Is Kendall's Tau-b the same as Spearman correlation?

No. Kendall's tau-b is based on concordant and discordant pairs with tie correction. Spearman correlation is Pearson correlation applied to ranked values.

Can SPSS calculate Kendall's Tau-b?

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

Can Excel calculate Kendall's Tau-b?

Yes, but it requires pair classification formulas. The Excel workbook in this guide shows concordant pairs, discordant pairs, tie counts and the final tau-b formula.

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