Skip to content
Lesson 9 of 10 · Introductory Statistics

Correlation and regression

Describe a relationship between two quantitative variables with a scatterplot, r and the least-squares line, and interpret slope, R² and residuals.

24 min

Scatterplot and correlation

A scatterplot shows the form (linear or curved), direction (positive or negative), strength and outliers. The correlation r (between −1 and 1) measures the strength and direction of a linear relationship.

  • r near 1 or −1: points close to a line. r near 0: no linear pattern (there may still be a curve).
  • r has no units and does not change if you swap x and y.
  • Correlation is not causation. Ice-cream sales and drownings are positively correlated because of a third factor, hot weather. This is a lurking variable.

The line ŷ = a + bx that makes the sum of squared vertical errors smallest has

  • slope b = r · (s_y / s_x) = S_xy / S_xx, where S_xy = Σ(x − x̄)(y − ȳ) and S_xx = Σ(x − x̄)²,
  • intercept a = ȳ − b x̄, so the line always passes through (x̄, ȳ).

Interpret the slope in context: 'for each extra hour of study, the predicted score rises by b points'. The intercept is the prediction at x = 0, which is often meaningless.

A residual is observed − predicted = y − ŷ. A plot of residuals against x should look like random scatter; a curve means a line is the wrong model. R² = r² is the share of the variation in y accounted for by the linear relationship with x.

  • Extrapolation (predicting far outside the x-range of your data) is unreliable.
  • Outliers, especially far out in x, can pull the line strongly.

Hours studied x and test score/10 y for five students: (1, 2), (2, 3), (3, 5), (4, 4), (5, 6). Find the least-squares line, r, and the prediction at x = 6.

  1. 1

    x̄ = 3, ȳ = 4

    Means.

1/6
Try it

With a = 1.3, b = 0.9 and x = 6 you get 6.7. Change x to 3: you get 4.0, the mean of y, because the line passes through (x̄, ȳ). Try x = 40: the formula happily answers, but would you trust it?

1.3
0.9
6.0

Predicted ŷ

—

Common misconception

“A strong correlation shows that x causes y.”

If two things move together, the simplest story is that one drives the other.

What is actually true

Correlation only measures how closely two variables move together. A lurking variable may drive both, the direction may be reversed, or it may be chance. Only a randomised experiment supports a causal claim.

How to catch yourself

Ask: could a third variable explain both? Could it run the other way?

  • r measures the strength and direction of a linear relationship, from −1 to 1.
  • Least-squares slope b = S_xy/S_xx; intercept a = ȳ − b x̄.
  • Interpret the slope in context, as the predicted change in y for one unit of x.
  • R² = r² is the share of variation in y explained by the line.
  • Do not extrapolate far beyond the data, and never infer causation from correlation alone.
Check yourself

Practice.

1Numeric answer

A least-squares line is ŷ = 2 + 3x. Predict y for x = 4.

2Numeric answer

If r = −0.8, what is R² (as a decimal)?

3Numeric answer

A student with x = 3 has y = 5 and predicted ŷ = 4.2. What is the residual?

4Multiple choice

A study finds r = 0.7 between hours of TV and weight. The best conclusion is:

  • ATV causes weight gain
  • Bweight gain causes TV watching
  • Cthe variables are linearly associated; causation is not established
  • Dthe variables are unrelated
5Multiple choice

The least-squares line always passes through:

  • A(0, 0)
  • B(x̄, ȳ)
  • Cthe first data point
  • Dthe largest point

Practise this lesson, not just read it

In BiliMind the questions above are marked when you answer, the flashcards come back on a schedule, and the rest of Introductory Statistics is planned around your week. Free.