Statistics How To

Spearman Rank Correlation (Spearman’s Rho): Definition and How to Calculate it

Statistics Definitions > Spearman Rank Correlation / Spearman’s Rho

What is Spearman Rank Correlation / Spearman’s Rho?

The Spearman rank correlation coefficient, rs, is the nonparametric version of the Pearson correlation coefficient. Your data must be ordinal, interval or ratio. Spearman’s returns a value from -1 to 1, where:
+1 = a perfect positive correlation between ranks
-1 = a perfect negative correlation between ranks
0 = no correlation between ranks.


  1. Tied ranks example.
  2. What to do with tied ranks.

Spearman Rank Correlation: Worked Example (No Tied Ranks)

The formula for the Spearman rank correlation coefficient when there are no tied ranks is:
rank correlation coefficient formula

Sample Question:
The scores for nine students in physics and math are as follows:
Physics: 35, 23, 47, 17, 10, 43, 9, 6, 28
Mathematics: 30, 33, 45, 23, 8, 49, 12, 4, 31
Compute the student’s ranks in the two subjects and compute the Spearman rank correlation.

Step 1: Find the ranks for each individual subject. I used the Excel rank function to find the ranks. If you want to rank by hand, order the scores from greatest to smallest; assign the rank 1 to the highest score, 2 to the next highest and so on:
spearman rank correlation 1

Step 2: Add a third column, d, to your data. The d is the difference between ranks. For example, the first student’s physics rank is 3 and math rank is 5, so the difference is 3 points. In a fourth column, square your d values.
spreaman 2

Step 4: Sum (add up) all of your d-squared values.
4 + 4 + 1 + 0 + 1 + 1 + 1 + 0 + 0 = 12. You’ll need this for the formula (the Σ d2 is just “the sum of d-squared values”).

Step 5: Insert the values into the formula. These ranks are not tied, so use the first formula:
rank correlation coefficient formula

= 1 – (6*12)/(9(81-1))
= 1 – 72/720
= 1-0.1
= 0.9
The Spearman Rank Correlation for this set of data is 0.9.

Spearman Rank Correlation: Worked Example (Tied Ranks)

Tied ranks are where two items in a column have the same rank. A couple of different formulas exist for dealing with tied ranks. Perhaps the easiest way is to use the mean of the tied ranks.

Let’s say two items in the above example tied for ranks 5 and 6. You would assign each data point a mean rank of 5.5:

Use the same formula, this time inserting the d-squared value for the tied ranks (14.5 from the new data):
rank correlation coefficient formula

= 1 – (6*14.5)/(9(81-1))
= 1 – 87/720
= 1 – 0.120833333
= 0.879

Check out our YouTube channel for hundreds of statistics help videos!

Spearman Rank Correlation (Spearman’s Rho): Definition and How to Calculate it was last modified: May 8th, 2017 by Andale

16 thoughts on “Spearman Rank Correlation (Spearman’s Rho): Definition and How to Calculate it

  1. Bokhietops

    Thank you for the step by step guidelines. I’m beginning to enjoy my subject because of your assistance. VerY stunning, correct an prompt.

  2. Bokhietops

    I’m beginning to enjoy my subject because of your assistance. VerY stunning, correct an prompt.

  3. joy

    thanks for the help If three judges are judging contestants, using spearmans rank correlaton how do u find the best Or the top three winners in the contest of 7 people

  4. Andale Post author

    Hello, Joy,
    Can you post this on our homework help forum? One of our mods will be happy to help. Thanks!

  5. Andale Post author

    If you have just r, n could be anything. For example, a set of 100, 1000, or 10000 numbers could all have the same r value. I think you’d need a little more info to come up with n.

  6. Penny

    I successfully worked through the above example, using your step by step. However, I have tied ranks in my dataset, and am unable to decipher the formula for that. Do you have a step-by-step for data with tied ranks?

  7. Andale Post author

    Not yet — it’s in the plan for the future though.
    The formula is very similar to how you work the Pearson Correlation (with summations of differences). It’s very cumbersome — good luck :)

  8. semir h

    hi i have one question regarding to spearman rank correlation .how can i compute for the given three rank using spearman rank correlation coefficient in order to find the nearest approach

  9. Andale Post author

    Hello, Semir,
    Could you rephrase your question, please? I don’t understand quite what you mean when you say “find the nearest approach”.


    thankyou so much for the helps a lot..but would you mind explain further on how to get the /d/, for an instance the X variable is 5 and Y variable is 7 why is that the d squared is positive not negative.?

  11. Andale Post author

    Do you mean d, the difference between ranks? D squared will always result in a positive number because a negative times a negative is a positive.

Leave a Reply

Your email address will not be published. Required fields are marked *