ExamSaathi learning library · Government exams · SSC CGL quantitative foundations; published syllabus labelled 2024 · Quantitative aptitude
Spearman's rank correlation: comparing two rankings
Compare two rankings of the same items with Spearman's rank correlation R = 1 - 6 x sum of d^2 / (n(n^2 - 1)), handle tied values with average ranks and the tie-adjusted (correction-factor) formula, and work back from R to the sum of d^2 or the number of items.
Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.
You will learn to
- Rank two sets of values and calculate Spearman's rank correlation coefficient R = 1 - 6 x sum of d^2 / (n(n^2 - 1)).
- Give tied values an average rank and find Spearman's R by the tie-adjusted formula, adding m(m^2 - 1)/12 for every tied group.
- Work back from a given rank correlation coefficient to the sum of d^2 or to the number of items ranked.
- Interpret a rank correlation of R = 1 or R = -1 as identical or exactly reversed rankings by two judges.
Before you start
Some qualities are easier to put in order than to measure: how sweetly a child sings, how neat a rangoli is, how crisp a batch of jalebis turns out. When two judges, or two tests, place the same n items in order, Spearman's rank correlation measures how closely the two orders agree. A rank is a position in an order. In this lesson rank 1 goes to the highest value or the best performance, rank 2 to the next, and so on down to rank n, unless a question says otherwise. Whichever direction is chosen, use it for both lists. Marks or other measured values can be turned into ranks first and then handled in the same way. As in the other lessons, x stands for multiplication.
Spearman's formula
Give each item its two ranks and find d = (rank in the first list) - (rank in the second list). The d values always add up to 0, which gives a quick check on the ranking. Square each d and add the squares. When no values are tied, Spearman's coefficient is R = 1 - 6 x sum of d^2 / (n(n^2 - 1)), where n is the number of items ranked, and this formula gives the exact coefficient. Handy values: n(n^2 - 1) is 5 x 24 = 120 for 5 items, 6 x 35 = 210 for 6 and 7 x 48 = 336 for 7. R always lies from -1 to +1. Identical rankings make every d zero, so R = 1. Exactly reversed rankings give the largest possible sum of d^2, namely n(n^2 - 1)/3, and then R = 1 - 2 = -1. A value near 0 means the two orders have little to do with each other.
Tied values share an average rank
When two or more items have equal values, they would fill several places between them, so each of them gets the average of those places. If two students tie for the 2nd and 3rd places, each gets rank (2 + 3) / 2 = 2.5, and the next student gets rank 4. If three tie for the 4th, 5th and 6th places, each gets (4 + 5 + 6) / 3 = 5, and the next one gets rank 7. The ranks in each list still add up to n(n + 1)/2. With ties, the usual textbook method is the tie-adjusted (correction-factor) formula: for every group of m tied items, in either list, add m(m^2 - 1)/12 to the sum of d^2, then use R = 1 - 6 x (sum of d^2 + all the corrections) / (n(n^2 - 1)). A tied pair (m = 2) adds 2 x 3 / 12 = 0.5, and a group of three (m = 3) adds 3 x 8 / 12 = 2. Be clear about what this gives. Without ties the plain formula is exact. With ties the adjusted formula is a textbook convention, not the exact coefficient, which is Karl Pearson's r worked on the two columns of average ranks. The two are often near each other, as in worked example 2 (0.6 adjusted, about 0.647 exact), but with many ties they can differ a lot. When a question asks for R by the tie-adjusted formula, give the adjusted value.
Working back from a known R
Without ties, the formula links R, the sum of d^2 and n, so any one of them can be found from the other two. Rearranged, sum of d^2 = (1 - R) x n(n^2 - 1) / 6; for 9 items with R = 0.9 this gives 0.1 x 720 / 6 = 12. To find n, first work out n(n^2 - 1) = 6 x sum of d^2 / (1 - R), then try whole numbers: n(n^2 - 1) is 120 for 5, 210 for 6, 336 for 7, 504 for 8, 720 for 9 and 990 for 10. A related task is fixing a copying slip: if one d^2 entry was written wrongly, take the wrong square out of the total, put the right one in and recalculate R. Without ties every d is a whole number, and since the d values add up to 0, the sum of d^2 always comes out even; an odd total means a slip somewhere.
Common mistakes
Ranking one list from the highest value and the other from the lowest, which turns the sign of R the wrong way. Forgetting to square d, or adding the d values themselves, which always gives 0. Writing n^2 - 1 alone in the bottom line instead of n(n^2 - 1). Working out 6 x sum of d^2 / (n(n^2 - 1)) and forgetting to subtract it from 1. Giving tied items the first of their shared places, such as 2 and 2, instead of the average, 2.5 and 2.5. When the tie-adjusted formula is asked for, leaving out the m(m^2 - 1)/12 corrections, or adding one correction for the whole table instead of one for every tied group in each list. Accepting an R above 1 or below -1, which always points to an arithmetic slip.
A routine for rank correlation questions
1. Choose the direction (rank 1 for the highest unless told otherwise) and use it for both lists. 2. Rank each list on its own, giving tied items the average of the places they share. 3. Find d for every item and confirm that the d values total 0. 4. Square the d values and add them. 5. If there are ties, use the tie-adjusted formula: for each tied group of m items, in either list, add m(m^2 - 1)/12 to that total. 6. Work out R = 1 - 6 x (total) / (n(n^2 - 1)). Without ties this R is exact; with ties it is the tie-adjusted (textbook) value, which can differ from the exact coefficient. 7. Check that R lies from -1 to +1. R near 1 means the two lists mostly agree, and R near -1 means one list is close to the other turned upside down.
Worked examples
At a school music contest in Lucknow, two judges ranked seven singers, with rank 1 for the best. The ranks (Judge 1, Judge 2) were: Aarti (4, 4), Bhavesh (1, 3), Chetna (6, 7), Dev (3, 1), Farah (7, 5), Gopal (2, 2) and Ishita (5, 6). Find Spearman's rank correlation coefficient R.
- d = Judge 1 rank - Judge 2 rank: Aarti 0, Bhavesh -2, Chetna -1, Dev 2, Farah 2, Gopal 0, Ishita -1.
- Check: 0 - 2 - 1 + 2 + 2 + 0 - 1 = 0, as it must be.
- d^2: 0, 4, 1, 4, 4, 0 and 1, so the sum of d^2 = 14.
- n = 7, so n(n^2 - 1) = 7 x 48 = 336.
- R = 1 - 6 x 14 / 336 = 1 - 84 / 336 = 1 - 0.25 = 0.75.
Answer: R = 0.75, so the two judges largely agree on the order of the singers.
Six students scored these marks out of 70 in a science quiz (u) and a mathematics quiz (v): Kavya 62 and 48, Lalit 52 and 30, Meena 40 and 39, Nikhil 56 and 42, Omkar 62 and 42, Pooja 42 and 42. Rank each quiz with rank 1 for the highest mark and find R by the tie-adjusted formula.
- Science ranks: the two 62s share places 1 and 2, so each gets 1.5; then 56 is 3, 52 is 4, 42 is 5 and 40 is 6. Kavya 1.5, Lalit 4, Meena 6, Nikhil 3, Omkar 1.5, Pooja 5.
- Mathematics ranks: 48 is 1; the three 42s share places 2, 3 and 4, so each gets 3; then 39 is 5 and 30 is 6. Kavya 1, Lalit 6, Meena 5, Nikhil 3, Omkar 3, Pooja 3.
- d = science rank - mathematics rank: Kavya 0.5, Lalit -2, Meena 1, Nikhil 0, Omkar -1.5, Pooja 2. They total 0.
- d^2: 0.25, 4, 1, 0, 2.25 and 4, so the sum of d^2 = 11.5.
- Tie corrections: the science pair adds 2 x 3 / 12 = 0.5 and the mathematics group of three adds 3 x 8 / 12 = 2, so 2.5 in all.
- Tie-adjusted R = 1 - 6 x (11.5 + 2.5) / (6 x 35) = 1 - 84 / 210 = 1 - 0.4 = 0.6.
- For comparison, the exact coefficient, Karl Pearson's r worked on the two columns of average ranks, is about 0.647; here the two values happen to be close, but they are not equal.
Answer: By the tie-adjusted formula R = 0.6, a moderate positive agreement between the two quiz rankings; the exact coefficient is about 0.647.
Two judges ranked the entries in a rangoli competition in Indore. There were no ties, their rankings gave R = 0.75, and the sum of d^2 was 30. How many entries were ranked?
- From 0.75 = 1 - 6 x 30 / (n(n^2 - 1)), the fraction 180 / (n(n^2 - 1)) must equal 1 - 0.75 = 0.25.
- So n(n^2 - 1) = 180 / 0.25 = 720.
- Try whole numbers: 8 x 63 = 504 is too small, while 9 x 80 = 720 fits exactly.
- Check: R = 1 - 180 / 720 = 1 - 0.25 = 0.75.
Answer: 9 entries were ranked.
Practice checks
- Two teachers ranked five science models, with rank 1 for the best. Teacher 1 gave Anu 1, Bela 2, Chirag 3, Dhruv 4 and Esha 5. Teacher 2 gave Anu 2, Bela 3, Chirag 1, Dhruv 4 and Esha 5. Spearman's R is:
- For 10 items ranked with no ties, Spearman's R = 0.6. The sum of d^2 is:
- Two judges rank 6 singers in exactly opposite orders: the singer one judge places 1st, the other places 6th, and so on. The sum of d^2 is:
- Seven marks are ranked with rank 1 for the highest: 80, 72, 72, 72, 65, 65 and 58. In the tie-adjusted formula, what total correction is added to the sum of d^2 for this list?
- Riya's rank table for six items has d values 1, -2, 0, 3, -1 and 1. What should she do first?
Sources checked
- SSC CGL Scheme and Syllabus, labelled 2024 — Tier-II Paper-II Statistics (correlation and regression: Spearman's rank correlation); not verified as the full 2026-cycle syllabus
- NCERT, Statistics for Economics, Textbook for Class XI — Chapter 6, Correlation: Spearman's rank correlation coefficient computed from differences of ranks, including tied ranks; mathematical relationships only