Statistics & correlation · Lesson 3 of 3

Correlation and lines of best fit

Spearman's rank correlation coefficient from ranks or raw scores, what the value means, scatter diagrams, and a line of best fit through the mean point.

  1. 1
  2. 2
  3. 3

When two quantities are measured for the same people or things (marks in two tests, days and heights), correlation describes how closely they move together. Further Maths measures it with Spearman’s coefficient and pictures it with a scatter diagram.

Spearman’s rank correlation

Rank each set of values separately (1 for the highest, or 1 for the lowest, but the same way for both). For each pair, find dd, the difference in ranks. Then:

ρ = 1 − 6Σd² ÷ n(n² − 1)d = rank in one list − rank in the otherρ near 1: strong agreement; near −1: strong disagreementnear 0: little or no relationship
Spearman's coefficientρ = 1 − 6Σd² ÷ n(n² − 1)

ρ\rho is always between −1-1 and 11. Close to 1 means the two rankings agree; close to −1-1 means they are reversed; close to 0 means little relationship.

Rank, subtract, squarePick a data set
test 1ranktest 2rankdd²
72368300
654605−11
80275200
55650600
90185100
60562411
2Σd²0.9429ρ = 1 − 6 × 2 ÷ (6 × 35)
Rank each list separately (1 for the highest), subtract the ranks, square and add. ρ = 0.9429: strong positive correlation between the two sets of marks.

Worked example · WAEC 2019

WAEC 2019 · Paper 2 · Q13

In a research to determine the relationship between performance of students in an entrance examination and subsequent school performance, the results of ten randomly selected students were obtained as follows:

Student A B C D E F G H I J
Entrance examination 11 12 8 13 6 15 10 14 17 16
School performance 5 10 9 7 4 8 6 14 11 12

Calculate the Spearman's rank correlation coefficient (3 d.p.).

What would be the researcher's conclusion from the result in (a)?

  1. Rank the entrance marks

    • I 17 → 1, J 16 → 2, F 15 → 3, H 14 → 4, D 13 → 5.
    • B 12 → 6, A 11 → 7, G 10 → 8, C 8 → 9, E 6 → 10.

    Think first. Rank 1 for the highest. Who has 17?

  2. Rank the school marks

    • H 14 → 1, J 12 → 2, I 11 → 3, B 10 → 4, C 9 → 5.
    • F 8 → 6, D 7 → 7, G 6 → 8, A 5 → 9, E 4 → 10.
  3. d and d²

    • A to J: d=−2, 2, 4, −2, 0, −3, 0, 3, −2, 0{d = -2,\ 2,\ 4,\ -2,\ 0,\ -3,\ 0,\ 3,\ -2,\ 0}.
    • Squares: 4, 4, 16, 4, 0, 9, 0, 9, 4, 0{4,\ 4,\ 16,\ 4,\ 0,\ 9,\ 0,\ 9,\ 4,\ 0}.
    • Add them: ∑d2=50{\sum d^2 = 50}.

    Think first. Subtract the ranks for each student, then square.

  4. The coefficient

    • ρ=1−6×50990=1−0.3030=0.697{\rho = 1 - \frac{6 \times 50}{990} = 1 - 0.3030 = 0.697}.
    • This is a fairly strong positive correlation: students who did well in the entrance examination tended to do well in school.

    Think first. n = 10, so n(n² − 1) = 990.

More: Spearman's rank correlation

Scatter diagrams and lines of best fit

Plot each pair as a point. If the points lie roughly along a line, draw the line of best fit. It should pass through the mean point (xˉ,yˉ)(\bar x, \bar y); a second point, such as the mean of the lower half of the data, fixes its direction.

(x̄, ȳ)
Line of best fitThrough the mean point (x̄, ȳ)

Worked example · WAEC 2013

WAEC 2013 · Paper 2 · Q13

Number of days (xx) 10 20 30 40 50 60 70 80
Height (yy m) 1.0 1.1 1.2 1.4 1.6 1.8 2.0 2.3

The table gives the relationship between the height, in metres, of a plant and the number of days it is left to grow.

Using a scale of 2 cm to 0.5 units on the yy-axis and 2 cm to 10 units on the xx-axis, draw the scatter diagram for the information.

Find xˉ\bar x, the mean of xx, and yˉ\bar y, the mean of yy, and plot (xˉ,yˉ)(\bar x, \bar y) on the diagram.

Draw the line of best fit to pass through (xˉ,yˉ)(\bar x, \bar y) and (10,1)(10, 1).

From the graph, find the: (i) equation of the line of best fit; (ii) height of the plant in 75 days.

  1. The mean point

    • xˉ=3608=45{\bar x = \frac{360}{8} = 45}.
    • yˉ=12.48=1.55{\bar y = \frac{12.4}{8} = 1.55}.

    Think first. Add the x values and the y values, and divide each by 8.

  2. The line

    • Gradient =1.55−145−10=0.5535=11700≈0.0157{= \frac{1.55 - 1}{45 - 10} = \frac{0.55}{35} = \frac{11}{700} \approx 0.0157}.
    • So y=1+11700(x−10){y = 1 + \frac{11}{700}(x - 10)}, which is about y=0.016x+0.84{y = 0.016x + 0.84}.

    Think first. The line passes through (10, 1) and (45, 1.55). What is its gradient?

  3. Height at 75 days

    • y=1+11700×65≈2.02{y = 1 + \frac{11}{700} \times 65 \approx 2.02} m.

More: scatter diagrams

Your turn

WAEC 2022 · Paper 2 · Q6

Vocal (XX) 63 69 72 59 82 91 95 68
Instrumental (YY) 58 61 67 51 53 79 92 57

The table shows the scores obtained by a group of artistes in Vocal (XX) and Instrumental (YY) musical competition.

  1. (a)

    Calculate the Spearman's rank correlation coefficient between the scores (3 d.p.).

Worked solution (try it first)
  1. Rank the Vocal scores (1 for the highest): 7,5,4,8,3,2,1,67, 5, 4, 8, 3, 2, 1, 6.
  2. Rank the Instrumental scores: 5,4,3,8,7,2,1,65, 4, 3, 8, 7, 2, 1, 6.
  3. dd: 2,1,1,0,−4,0,0,02, 1, 1, 0, -4, 0, 0, 0, so ∑d2=4+1+1+16=22\sum d^2 = 4 + 1 + 1 + 16 = 22.
  4. ρ=1−6×228×63\rho = 1 - \dfrac{6 \times 22}{8 \times 63}
    =1−132504= 1 - \dfrac{132}{504}
    =3142= \dfrac{31}{42}
    ≈0.738\approx 0.738.

Report a problem with this question