Spearman Rank Correlation Calculator

Spearman’s rank correlation (rho) for paired data, with average ranks for ties, the t statistic and an approximate two-sided p-value.

Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.
Pair each y with the x in the same position. 3 to 1000 pairs.

Results

Spearman’s rho (ρ)
-0.763
t statistic
-4.7221
p-value (two-sided, from the t distribution)
0.0002
Degrees of freedom (n − 2)
16
Number of pairs (n)
18
Ranks of x
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.5, 12.5, 14, 15, 16, 17, 18
Ranks of y
16, 18, 10, 7, 8, 17, 12, 15, 14, 13, 11, 5, 9, 6, 4, 1, 3, 2
Ties
Yes: tied values share the average of the ranks they span
Reliability of the p-value
Approximation is reasonable for 11 or more pairs.

How it’s calculated

Spearman’s rank correlation measures how well the relationship between two variables can be described by a monotonic function: as x goes up, does y tend to go up (positive) or down (negative), whether or not the trend is a straight line? It replaces each value by its rank (1 for the smallest) and then takes the ordinary Pearson correlation of the ranks. Tied values get the average of the ranks they would have shared.

rank each list (1 = smallest, ties share the average rank) ρ = Pearson correlation of the two lists of ranks without ties: ρ = 1 − 6 Σd² ÷ (n(n² − 1)), d = rank of x − rank of y t = ρ √(n − 2) ÷ √(1 − ρ²), df = n − 2 (p-value from Student's t, two-sided)

The p-value tests the null hypothesis that ρ = 0 and is an approximation; with 10 or fewer pairs an exact table is preferred. When ρ = ±1 the t formula breaks down; with no ties a perfect ranking is one of n! equally likely orders, so the exact two-sided p-value 2 ÷ n! is shown instead. A significant ρ shows an association, not that one variable causes the other.

Example (from the Handbook of Biological Statistics, LibreTexts): the pouch volume and drumming frequency of 18 male magnificent frigatebirds give ρ ≈ −0.76 with 16 degrees of freedom and P ≈ 0.0002. The default values are that data set (the two values of 5090 share rank 12.5).

Frequently asked questions

When should I use Spearman instead of Pearson?

Use Spearman when the relationship is monotonic but not necessarily straight, when there are outliers, or when the data are ranks rather than measurements. For roughly linear data with no gross outliers, Pearson’s r is usually preferred.

How are ties handled?

Tied values are given the average of the ranks they span, and ρ is the Pearson correlation of those ranks. This is the standard approach and it is why the shortcut formula with Σd² is not used when there are ties.

What does ρ near 0 mean?

There is little monotonic trend. A strong curved relationship that rises and then falls can still give ρ near 0.

Is the p-value exact?

No. It uses the t distribution approximation described by the Handbook of Biological Statistics, which works well from about 11 pairs. For smaller samples, check an exact critical-value table.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator