Reading history

Correlation and Regression

4 min read 2 views

Read scatter diagrams, calculate Pearson's r and the regression line y = a + bx, make predictions, and use Spearman's rank correlation.

Do students who study longer get higher marks? Does the price of rice go up when rainfall goes down? Questions like these are about two variables at once. Correlation measures how strongly two variables move together. Regression finds the best straight line through the data, so we can make predictions. This lesson shows how to calculate both and how to use them with care.

In this lesson you will learn

  • How to read a scatter diagram
  • Pearson’s correlation coefficient r
  • The regression line of y on x
  • How to make predictions, and why extrapolation is risky
  • Spearman’s rank correlation
  • Why correlation does not prove cause

You should know measures of dispersion and the equation of a straight line.

Scatter Diagrams

Plot each pair (x, y) as a point. The pattern of the points shows the relationship.

  • Positive correlation: as x goes up, y tends to go up.
  • Negative correlation: as x goes up, y tends to go down.
  • No correlation: no clear pattern.

The closer the points lie to a straight line, the stronger the correlation.

Pearson’s Correlation Coefficient

We measure the strength with a number r between −1 and 1. First work out three sums.

Sxx = Σ(x − x̄)²
Syy = Σ(y − ȳ)²
Sxy = Σ(x − x̄)(y − ȳ)

r = Sxy / √(Sxx × Syy)
Value of rMeaning
1Perfect positive: all points on a rising line
0.7 to 1Strong positive
around 0No linear relationship
−1 to −0.7Strong negative
−1Perfect negative: all points on a falling line

A Worked Example

Hours studied (x):  1   2   3   4   5      x̄ = 3
Marks (y):         50  55  65  70  80      ȳ = 64

x − x̄:   −2   −1    0    1    2
y − ȳ:  −14   −9    1    6   16

Sxx = 4 + 1 + 0 + 1 + 4         = 10
Syy = 196 + 81 + 1 + 36 + 256   = 570
Sxy = 28 + 9 + 0 + 6 + 32       = 75

r = 75 / √(10 × 570) = 75 / 75.50 ≈ 0.993

r is very close to 1, so there is a very strong positive correlation.

The Regression Line

The regression line of y on x is the straight line y = a + bx that fits the points best. It makes the sum of the squared vertical distances from the points to the line as small as possible.

Formulas

b = Sxy / Sxx    and    a = ȳ − b x̄

b = 75/10 = 7.5
a = 64 − 7.5 × 3 = 41.5

y = 41.5 + 7.5x

Prediction for 3.5 hours: y = 41.5 + 7.5 × 3.5 = 67.75 marks
123456405060708090hours studied (x)marks (y)(x̄, ȳ) = (3, 64)y = 41.5 + 7.5x

The line always passes through the mean point (x̄, ȳ). The slope b tells us that each extra hour adds about 7.5 marks.

Interpolation and extrapolation

Predicting inside the range of the data (here 1 to 5 hours) is called interpolation and is fairly safe. Predicting outside it is extrapolation. The line gives 116.5 marks for 10 hours, which is impossible. The pattern may not continue.

There is also a regression line of x on y, x = c + dy with d = Sxy / Syy. It is used to predict x from y. The two slopes are linked: b × d = r².

Spearman’s Rank Correlation

Sometimes we only have ranks, such as two judges ranking contestants. Then use

rs = 1 − 6Σd² / (n(n² − 1))       d = difference in ranks

Contestant:   P   Q   R   S   T
Judge 1:      1   2   3   4   5
Judge 2:      2   1   4   3   5
d:           −1   1  −1   1   0     Σd² = 4

rs = 1 − 6 × 4 / (5 × 24) = 1 − 0.2 = 0.8

The judges agree quite strongly.

Correlation Is Not Cause

Ice cream sales and drowning cases both rise in summer. They are correlated, but ice cream does not cause drowning. Hot weather affects both. A strong r shows that two things move together. It does not show that one causes the other.

Common Mistakes

  1. Saying r = 0 means no relationship. It means no straight-line relationship; there may be a curve.
  2. Extrapolating far beyond the data.
  3. Using the y-on-x line to predict x. Use the x-on-y line for that.
  4. Treating correlation as proof of cause.

Practice Exercises

Exercise 1. Given Sxy = −40, Sxx = 20 and Syy = 100, find r and the slope b of the y-on-x line.

Show answer

r = −40/√2000 ≈ −0.894, a strong negative correlation. b = −40/20 = −2.

Exercise 2. Use y = 41.5 + 7.5x to predict the mark for 4 hours of study.

Show answer

y = 41.5 + 30 = 71.5 marks.

Exercise 3. For 4 items, Σd² = 2. Find Spearman’s rank correlation.

Show answer

rs = 1 − 6 × 2 / (4 × 15) = 1 − 12/60 = 0.8.

Frequently Asked Questions

Can r be bigger than 1?

No. r always lies between −1 and 1. If your answer is outside this range, check the arithmetic.

Why is it called “regression”?

The name comes from Francis Galton. He found that very tall parents tend to have children who are tall but closer to the average height. The children’s heights “regressed” towards the mean.

Summary

  • A scatter diagram shows positive, negative or no correlation.
  • r = Sxy/√(Sxx Syy) lies between −1 and 1.
  • The y-on-x regression line is y = a + bx with b = Sxy/Sxx and a = ȳ − b x̄.
  • Spearman’s rs = 1 − 6Σd²/(n(n² − 1)) works with ranks.
  • Correlation does not prove cause; avoid extrapolation.

Next: The Binomial Distribution.

Lessons are also marked complete when you click Next.

Leave a Reply

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