Correlation and regression

The product moment correlation coefficient r measures how closely points lie to a straight line. It goes from −1 (perfect negative) through 0 (none) to +1 (perfect positive). The least squares regression line y = a + bx is the best straight line for predicting y from x.

Key facts

  • Sxx = Σx² − ((Σx)²)/n, Syy = Σy² − ((Σy)²)/n, Sxy = Σxy − ((Σx)(Σy))/n.
  • r = Sxy ÷ √(Sxx × Syy). It is always between −1 and 1.
  • Regression line of y on x: b = Sxy/Sxx and a = ȳ − bx̄.
  • The regression line always passes through the mean point (x̄, ȳ).
  • b is the change in y for each extra unit of x. a is the value of y when x = 0.
  • Use the line of y on x to predict y from x, and only within the range of the data.
  • Changing units (linear coding with positive multipliers) does not change r.

Worked examples

Example 1

The correlation coefficient between hours of daylight and heating costs is r = −0.92. Describe the correlation.

  1. The sign is negative. More daylight goes with lower heating costs.
  2. −0.92 is close to −1, so the correlation is strong.

Answer: Strong negative correlation

Example 2

Find the regression line of y on x for x: 1, 2, 3, 4, 5 and y: 3, 5, 4, 7, 8.

  1. Work out the sums. Σx = 15, Σy = 27, Σxy = 93, Σx² = 55
  2. Work out Sxy and Sxx. Sxy = 93 − (15 × 27)/5 = 12, Sxx = 55 − (15²)/5 = 10
  3. Gradient: b = 12 ÷ 10 = 1.2
  4. Intercept, using the means 3 and 5.4: a = ȳ − bx̄ = 5.4 − 1.2 × 3 = 1.8

Answer: y = 1.8 + 1.2x

Example 3

For the same data, find the product moment correlation coefficient.

  1. Find Syy, using Σy² = 163. Syy = 163 − (27²)/5 = 17.2
  2. Use the formula for r. r = 12 ÷ √(10 × 17.2) = 0.915
  3. This is strong positive correlation, so the line is a good model.

Answer: r = 0.915

Example 4

The correlation coefficient for two variables is r = 0.85. Describe the correlation.

  1. r is positive, so as one variable increases the other tends to increase.
  2. 0.85 is close to 1, so the correlation is strong.

Answer: Strong positive correlation

Example 5

The regression line is y = 3.2x + 5. Estimate y when x = 10.

  1. Put x = 10 into the equation. 3.2 × 10 + 5 = 37

Answer: 37

Example 6

In the regression line y = 3.2x + 5, what does the gradient 3.2 tell you?

  1. The gradient is the change in y for each increase of 1 in x.
  2. So y goes up by about 3.2 each time x goes up by 1.

Answer: y goes up by about 3.2 for each increase of 1 in x

Example 7

A correlation coefficient is r = −0.9. Describe the correlation.

  1. r is negative, so as one variable increases the other tends to decrease.
  2. −0.9 is close to −1, so the correlation is strong.

Answer: Strong negative correlation

Example 8

Why can r be close to 0 even when two variables are strongly related?

  1. r measures how close the points are to a straight line.
  2. A strong curved pattern, such as a U shape, can still give r close to 0.

Answer: r only measures a straight-line relationship