impera Open Impera

IB Diploma Mathematics AA · Statistics and probability

Linear correlation and regression

1Scatter diagrams and correlation

A scatter diagram plots pairs of data $(x, y)$ to see whether two variables are related.

A scatter diagram with its regression line

  • Positive correlation: as $x$ increases, $y$ tends to increase.
  • Negative correlation: as $x$ increases, $y$ tends to decrease.
  • No correlation: no clear pattern.

The independent variable goes on the $x$-axis and the dependent variable on the $y$-axis.

Correlation does not mean causation. Ice cream sales and drownings both rise in summer, but one does not cause the other. A third variable, the temperature, drives both.

Check yourself

Ice cream sales and sunburn cases are strongly correlated. What can you conclude?

  • Eating ice cream causes people to get sunburn

  • They are related, but one need not cause the other

  • Sunburn causes people to buy more ice cream

  • The data must be wrong, as they are unrelated

Show the answer

They are related, but one need not cause the other

Hot sunny weather increases both.

2Pearson's correlation coefficient

Pearson's product-moment correlation coefficient, $r$, measures the strength of a linear relationship. You find it with your GDC.

  • $r$ is always between $-1$ and $1$.
  • $r = 1$ is perfect positive, $r = -1$ is perfect negative, $r = 0$ is no linear correlation.
  • Roughly: $|r| > 0.75$ is strong, $0.5$ to $0.75$ is moderate, $0.25$ to $0.5$ is weak, and below $0.25$ is very weak.

$r$ only measures straight-line patterns. Data on a clear curve can have $r$ close to 0.

Check yourself

What does r = −0.92 tell you?

  • A strong positive linear correlation

  • No linear correlation of any kind

  • A weak negative linear correlation

  • A strong negative linear correlation

Show the answer

A strong negative linear correlation

The sign gives the direction and the size gives the strength.

3The regression line

The least squares regression line of $y$ on $x$ is the line $y = ax + b$ that makes the squared vertical distances from the points as small as possible. Your GDC gives $a$ and $b$.

  • The line always passes through the mean point $(\bar{x}, \bar{y})$.
  • The gradient $a$ means: for each extra unit of $x$, $y$ changes by about $a$.
Worked example

Hours of study and test score

  1. Eight students: hours $x$ = 1 to 8, scores $y$ = 45, 46, 52, 55, 58, 64, 66, 72.
  2. GDC: $y = 3.90x + 39.7$ and $r = 0.993$.
  3. Interpretation: each extra hour of study adds about 3.9 marks.
  4. Prediction for 6.5 hours: $3.90 \times 6.5 + 39.7 = 65.1$ marks.
  5. This is reliable, because $r$ is very strong and 6.5 is inside the data range.
Check yourself

Which point always lies on the regression line?

  • The origin

  • The point with the largest y

  • The mean point (x̄, ȳ)

  • The first data point

Show the answer

The mean point (x̄, ȳ)

The least squares line is balanced around the means.

4Using the line safely

  • Interpolation: predicting inside the range of the data. This is usually reliable if the correlation is strong.
  • Extrapolation: predicting outside the range. This is unreliable, because the pattern may not continue.

Use the $y$ on $x$ line to predict $y$ from $x$. To predict $x$ from $y$, use the $x$ on $y$ line, $x = cy + d$, which the GDC also gives. The two lines are different unless $r = \pm 1$.

Worked example

An unsafe prediction

  1. Using the study line above, predict the score for 20 hours.
  2. $3.90 \times 20 + 39.7 = 117.7$ marks.
  3. This is extrapolation, and it gives more than 100%. The model has broken down.
Check yourself

Predicting a value far outside the data range is called:

  • Regression

  • Extrapolation

  • Correlation

  • Interpolation

Show the answer

Extrapolation

"Extra" means outside.

5Correlation is not causation

A strong correlation does not prove that one variable causes another.

  • Confounding variables: both variables may depend on a third. Ice-cream sales and sunburn both rise in hot weather.
  • Coincidence: unrelated variables can correlate by chance.
  • Reverse causation: the direction of cause may be the opposite of what is assumed.

Controlled experiments are needed to establish cause.

Check yourself

Ice-cream sales and drownings are positively correlated. What is the most likely explanation?

  • The correlation is impossible here

  • Drownings cause more ice-cream sales

  • A confounding variable: hot weather

  • Eating ice cream causes drowning

Show the answer

A confounding variable: hot weather

Third variable.

6Regression of x on y

The regression line of $y$ on $x$ predicts $y$ from $x$. To predict $x$ from $y$, use the regression line of $x$ on $y$, which is generally different.

Worked example

Hours studied and test score

  1. The regression line of score $(y)$ on hours $(x)$ is $y = 5x + 40$.
  2. Predict the score for 6 hours: $y = 70$.
  3. To predict hours from a score, calculate the $x$ on $y$ line with a GDC instead of rearranging.
  4. The two lines meet at the mean point $(\bar{x}, \bar{y})$.
Check yourself

Which point do both regression lines pass through?

  • The mean point $(\bar{x}, \bar{y})$

  • The largest data point

  • The origin, $(0, 0)$

  • The median point of the data set

Show the answer

The mean point $(\bar{x}, \bar{y})$

Always.

7Going deeper: interpreting GDC output in context

Most marks in regression questions are for interpretation. The GDC does the arithmetic.

Worked example

for 12 students, $x$ is hours of revision and $y$ is the test score. The GDC gives $r = 0.92$ and the regression line of $y$ on $x$: $y = 5.2x + 41$. The mean of $x$ is 5.

  1. Describe the correlation: strong, positive, linear. All three words are expected.
  2. Interpret the gradient: each extra hour of revision is associated with an increase of about 5.2 marks.
  3. Interpret the intercept: a student who does no revision is predicted to score about 41. Comment on whether $x = 0$ is inside the data range.
  4. Predict the score for 6 hours: $5.2 \times 6 + 41 = 72.2$. This is interpolation, inside the data range, and $r$ is high, so the estimate is reliable.
  5. Predict for 20 hours: $5.2 \times 20 + 41 = 145$, which is impossible on a 100-mark test. This is extrapolation: the linear pattern cannot be assumed outside the data.
  6. The mean point: the line passes through $(\bar{x}, \bar{y})$, so $\bar{y} = 5.2 \times 5 + 41 = 67$.

Which line?

  • The line of $y$ on $x$ predicts $y$ from $x$.
  • To predict $x$ from a given $y$, use the line of $x$ on $y$. Rearranging the $y$ on $x$ line is not valid unless the correlation is perfect.
  • Decide which variable is independent (explanatory) before you start.

Reading $r$

  • $r$ lies between $-1$ and $1$. Values near $\pm 1$ show a strong linear relationship; values near 0 show little linear relationship.
  • A rough guide for $|r|$: below 0.25 very weak; 0.25 to 0.5 weak; 0.5 to 0.75 moderate; above 0.75 strong.
  • $r = 0$ does not mean "no relationship". Points on a parabola can have $r$ close to 0.
  • $r$ is unchanged by a change of units.

Correlation is not causation

  • A lurking variable may drive both. Ice cream sales and drownings rise together because of hot weather.
  • The direction may be reversed: do students score highly because they revise, or do keen students both revise and score highly?
  • Coincidence is possible with small samples.

Checks before trusting a line

  • Look at the scatter diagram first. One outlier can change $r$ and the line considerably.
  • A curved pattern needs a different model.
  • A small sample gives an unreliable $r$.
Check yourself

A regression line of y on x is y = 3.1x + 12 and the mean of x is 10. What is the mean of y?

  • 12

  • 22

  • 43

  • 31

Show the answer

43

The line passes through the mean point, so ȳ = 3.1 × 10 + 12.

Now test yourself

This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.

Practise in Impera