Spearman's correlation coefficient

Calculates Spearman's rank correlation coefficient

This page exists due to the efforts of the following people:




Created: 2015-08-07 15:30:52, Last updated: 2021-03-03 08:23:46

This calculator below calculates Spearman's rank correlation coefficient between two random variables. The theoretical part is below the calculator.

PLANETCALC, Spearman's correlation coefficient

Spearman's correlation coefficient

Changes of random variables

Items per page:

Digits after the decimal point: 4
Spearman's correlation coefficient

The method of Spearman's rank correlation coefficient calculation is actually pretty simple. It's like the Pearson correlation coefficient but designed not for measurements of random variables only but their ranking values.

That is

We have only to understand what is the rank value and why all this is necessary.

If the elements of a variational series are arranged in ascending or descending order, that rank of the element will be his number in the ordered series.

For example, we have a variational series {17,26,5,14,21}. Let's sort it's elements in a descending order {26,21,17,14,5}. 26 has a rank of 1, 21 - rank of 2 and so on, Variational series of ranking values will look like this {3,1,5,4,2}.

I.e., when calculating Spearman's coefficient, initial variation series are converted into variational series of ranking values, and then Pearson's formula is applied to them.
There is one subtlety - the repeating values' rank is taken as the average of the ranks. That is, for a series {17, 15, 14, 15}ranking series will look like {1, 2.5, 4, 2.5}, as the first element is 15 has a rank of 2, and the second - rank of 3, and\frac{2+3}{2}=2.5.

If you don't have the repeating values, that is, all the values of the ranking series - the numbers between 1 and n, the Pearson's formula can be simplified to
By the way, this formula is often given as the formula for calculating the Spearman's coefficient.

What is the essence of the transition from the values themselves to their rank value?
When investigating the correlation of ranking values, you can find how well a monotonic function describes the dependence of the two variables.

The sign of the coefficient indicates the direction of the relationship between variables. If the sign is positive, Y's values tend to increase with the increase of X. If the sign is negative, the values of Y tend to decrease with the increase of X. If the coefficient is 0, there is no tendency then. If the coefficient equals 1 or -1, the relationship between X and Y has an appearance of monotonic function, i.e., with the increase of X, Y also increases and vice versa.

Unlike Pearson's correlation coefficient, which can detect only the linear relationship of one variable from another, Spearman's correlation coefficient can detect monotonic dependence, where the direct linear relationship cannot be revealed.

Here's an example.
Поясню на примере. Let's suppose,we examine the function y=10/x.
We have the following measurements of X and Y
{{1,10}, {5,2}, {10,1}, {20,0.5}, {100,0.1}}
For this data, the Pearson correlation coefficient is equal to -0.4686, i.e., the relationship is weak or absent. And Spearman's correlation coefficient is strictly equal to -1, as if it's hinting to the researcher that Y has strongly negative monotonic dependence from X.

URL copied to clipboard
PLANETCALC, Spearman's correlation coefficient