Advertisement

Spearman's rank correlation calculator

Measure monotonic association by correlating ranks. Keep the two observations in each pair together when entering the lists.

Calculator

Use commas, spaces or new lines between numbers. Use the same unit for every observation.

Use commas, spaces or new lines between numbers. Use the same unit for every observation.

Spearman's rank correlation
0.500000
Sum of squared rank differences
1.500000
Pair count
3.000000
Average ranks and differences
xyRank xRank yRank x - rank y
1.0000001.0000001.0000001.500000-0.500000
2.0000001.0000002.5000001.5000001.000000
2.0000002.0000002.5000003.000000-0.500000

Advertisement

How this calculator works

Each variable is ranked separately from smallest to largest. A tied group receives the average of the positions it occupies. Pearson correlation is then calculated on the two rank lists, which handles ties directly. The familiar shortcut based on squared rank differences is valid only without ties, so the displayed squared-difference total is a working quantity rather than the general formula used here. A constant variable has undefined rank correlation.

Formula

rho = Pearson(rank(x), rank(y)), using average ranks for ties. With no ties only: rho = 1 - 6Σd_i²/(n(n² - 1)).

Worked example

For x = 1, 2, 2 and y = 1, 1, 2, the ranks are 1, 2.5, 2.5 and 1.5, 1.5, 3. Their Pearson correlation is 0.5.

Advertisement

Frequently asked questions

Does Spearman require a straight line?

No. A consistent increasing or decreasing ordering can have strong Spearman correlation even when the raw relationship is curved.

Can I enter ranks I already calculated?

Yes, provided they describe matching pairs. Average-rank ties will be handled consistently when the values are ranked again.

Is a p-value included?

No. Inference with small samples and ties needs a specified test or permutation procedure. This tool reports the descriptive coefficient and its ranks.

Sources

Advertisement