Skip to study

CHAPTER 06 · STATISTICS & PROBABILITY

Correlation & regression

Progress stays on this device

papers AI SL chapter & section analysis

Your chapter

Use a scatter plot, correlation and regression together to make defensible predictions.

Read all chapter notes

6.1

Measuring correlation

Pearson’s product-moment correlation coefficient r measures the direction and strength of a linear association between paired numerical variables. It lies from −1 to 1; values near either end indicate a close straight-line pattern, while values near zero indicate little linear association.

Plot the data first. A curved pattern or influential unusual point can make r a poor summary of the relationship. Correlation is unchanged by adding constants to either variable and by multiplying by positive constants; multiplying one variable by a negative constant reverses its sign.

A correlation is not a regression gradient and does not measure a change in units. It does not establish a causal mechanism. Quote its value to the requested precision and interpret direction and linear strength in the particular variables; avoid calling zero correlation proof of independence.

r=SxySxxSyy\displaystyle r = \frac{S_{xy}}{\sqrt{S_{xx} S_{yy}}}, where Sxy=∑(x−x‾)(y−yˉ)\displaystyle S_{xy} = \sum \left(x - \overline{x}\right) \left(y - \bar{y}\right), Sxx=∑(x−x‾)2\displaystyle S_{xx} = \sum \left(x - \overline{x}\right)^{2} and Syy=∑(y−yˉ)2\displaystyle S_{yy} = \sum \left(y - \bar{y}\right)^{2}.

Watch out: A low Pearson correlation can conceal a strong curved relationship; r=0\displaystyle r = 0 is not a general independence test.

Worked example

Paired measurements have Sxy=18\displaystyle S_{xy} = 18, Sxx=25\displaystyle S_{xx} = 25 and Syy=16\displaystyle S_{yy} = 16. Find Pearson’s r.

  1. Compute SxxSyy=25×16=20\displaystyle \sqrt{S_{xx} S_{yy}} = \sqrt{25 \times 16} = 20.
  2. Therefore r=1820=910\displaystyle r = \frac{18}{20} = \frac{9}{10}.

6.2

The line of best fit

A least-squares regression line of y on x predicts the response y from a known predictor x. It minimizes the sum of squared vertical residuals and passes through the mean⁡\displaystyle \operatorname{mean} point (x‾, yˉ)\displaystyle \left(\overline{x},\,\bar{y}\right). A positive or negative gradient describes the modelled change in the response for each unit increase in the predictor.

Use a GDC to fit the paired observations and retain the full stored coefficients for predictions. Report the equation using the requested variables and units. Its intercept is the predicted response at x=0\displaystyle x = 0, but that interpretation may be unrealistic when zero lies outside the relevant domain.

Choose the regression direction according to what is being predicted. The regression of x on y generally differs from rearranging the regression of y on x. Reversing the two fitted directions only gives the same geometric line in a perfect linear fit.

For predicted y=a+bx\displaystyle y = a + bx: b=SxySxx\displaystyle b = \frac{S_{xy}}{S_{xx}} and a=yˉ−bx‾\displaystyle a = \bar{y} - \overline{bx}. The line passes through (x‾, yˉ)\displaystyle \left(\overline{x},\,\bar{y}\right).

Watch out: Do not swap the x and y lists or round the coefficients before a later calculation.

Worked example

A regression line of y on x has x‾=5\displaystyle \overline{x} = 5, yˉ=18\displaystyle \bar{y} = 18, Sxx=20\displaystyle S_{xx} = 20 and Sxy=48\displaystyle S_{xy} = 48. Find its slope and intercept, in that order.

  1. The slope is 4820=125=2.4\displaystyle \frac{48}{20} = \frac{12}{5} = 2.4.
  2. The mean⁡\displaystyle \operatorname{mean} point lies on the line, so the intercept is 18−2.4×5=6\displaystyle 18 - 2.4 \times 5 = 6.

6.3

Interpreting the regression line

Use the units and context to explain a fitted gradient: it is the predicted change in the response for an increase of one predictor unit. The intercept describes the model at input zero; explain if this is outside the observed range or meaningful domain.

Interpolation predicts at an input within the observed range. Extrapolation extends beyond that evidence and assumes the relationship continues; it is usually less reliable. A high correlation does not remove this concern, nor does it guarantee a useful prediction for every individual.

A residual equals observed minus predicted response. Positive residuals put observations above the fitted line; negative residuals put them below. A useful model should also be checked for systematic residual patterns, influential observations, sensible units and practical restrictions on its outputs.

Residual e=y\displaystyle e = y−ŷ. Prediction ŷ=a+bx\displaystyle a + bx. Use the observed input range to distinguish interpolation from extrapolation.

Watch out: A fitted model can produce an exact calculated number without that prediction being reliable or physically possible.

Worked example

A model predicts cooling time t=3.5m+8\displaystyle t = 3.5 m + 8 minutes. For one object, m=6\displaystyle m = 6 kg and observed cooling time is 32 minutes. Find the residual.

  1. The predicted cooling time is 3.5×6+8=29\displaystyle 3.5 \times 6 + 8 = 29 minutes.
  2. Residual=32−29=3\displaystyle 32 - 29 = 3 minutes; the object took longer than predicted.