Spearman Correlation Calculator
Spearman's rank correlation (rho) and Kendall's tau-b from paired data, with tied values handled and p-values for each.
Result…
How it's calculated
ρ = Pearson correlation of the ranks (average ranks for ties) no ties: ρ = 1 − 6Σd² ÷ (n(n² − 1)) t = ρ √((n − 2) ÷ (1 − ρ²)), df = n − 2 τ_b = (C − D) ÷ √((n₀ − n₁)(n₀ − n₂)), n₀ = n(n − 1) ÷ 2 z = (C − D) ÷ √Var(C − D)
Spearman's rho and Kendall's tau measure how well the relationship between two variables follows a single direction, whether or not it is a straight line, so they suit ranked data, scores with outliers and curved but steady trends. Rho is the ordinary Pearson correlation of the ranks; tied values get the average of the ranks they would share. Kendall's tau-b counts pairs of observations that agree (concordant) or disagree (discordant) in order, with an adjustment for ties; it is usually smaller than rho in size and its sampling behaviour is better understood for small samples. For a straight-line relationship between the raw values, Pearson's r is the usual measure.
Your numbers, step by step
About the Spearman Correlation calculator
This Spearman correlation calculator measures how closely two paired lists move in the same order, whether or not the relationship is a straight line. Paste the X and Y values and it ranks both lists, giving tied values the average of the ranks they share, and works out Spearman's rho as the Pearson correlation of those ranks. It also gives Kendall's tau-b, which counts the pairs of observations that agree or disagree in order, with an adjustment for ties. Each comes with a p-value, two-sided or one-sided: a t approximation for rho and a normal approximation with tie-corrected variance for tau, the defaults in most statistics software. The steps list the ranks, the t and z statistics and the counts of concordant and discordant pairs, so the result can be checked by hand. Use it for ranked data, scores with outliers or trends that curve.
How to use it
- Type or paste the “X values”, separated by commas, spaces or new lines.
- Type the “Y values” in the same order, so the first Y pairs with the first X.
- Choose the “Alternative”: two-sided if any association counts, or positive or negative if you predicted a direction before seeing the data.
- Read Spearman's rho and Kendall's tau-b with their p-values, and check the ranks in the steps.
Worked example
Ten people have IQ scores 86, 97, 99, 100, 101, 103, 106, 110, 112 and 113 and spend 0, 20, 28, 27, 50, 29, 7, 17, 6 and 12 hours a week watching TV. With no ties, the squared rank differences add up to 194, so rho = 1 − 6 × 194 ÷ (10 × 99) = −0.1758. Then t = −0.5050 with 8 degrees of freedom and the two-sided p-value is 0.6272. Kendall's tau-b is −0.1111 (5 more discordant than concordant pairs out of 45), with z = −0.4472 and p = 0.6547. Neither shows a real association.
Updated
Questions people ask
How do I calculate Spearman's rank correlation?
Rank each list from smallest to largest, giving tied values the average of their ranks, then work out the Pearson correlation of the two lists of ranks. With no ties this is the same as 1 − 6Σd² ÷ (n(n² − 1)), where d is the difference between each pair of ranks.
When should I use Spearman instead of Pearson correlation?
Use Spearman's rho or Kendall's tau when the data are ranks, when outliers would dominate, or when the relationship rises or falls steadily but not in a straight line. For a straight-line relationship between the raw values, use the correlation coefficient calculator.
What is the difference between Kendall's tau and Spearman's rho?
Rho correlates the ranks, while tau counts the pairs that are in the same order against those in the opposite order. Tau is usually smaller in size, is easier to interpret as a difference in probabilities, and behaves better in small samples.
How are tied values handled?
Tied values share the average of the ranks they would take up, so two values in 2nd and 3rd place both get 2.5. Kendall's tau-b and its variance include corrections for ties in both lists.
Does a rank correlation of 0 mean the variables are unrelated?
No. It means there is no steady upward or downward trend, but a U-shaped or cyclic pattern can still be strong. Always plot the data.
How accurate are the p-values for small samples?
Both p-values are approximations that work best with about 10 or more pairs. For very small samples without ties, exact tables or a permutation test give more reliable p-values, and the note says when the sample is small.