learn › Probability & Statistics

Correlation & regression

lesson · about 3 minutes

Lines of best fit, residuals, and what r means.

Pen and paper is fine · no calculator needed why?

Opens at level 43. You're level 1. You can read and practice here now.

the idea

A fitted line ŷ = a + bx turns an x into a prediction ŷ. The number a is the prediction when x is 0, and b, the slope, is how much the prediction changes for each extra unit of x. A residual is the miss: actual minus predicted.

The correlation r runs from −1 to 1. Its sign gives the direction, and its size says how tightly the points hug a straight line. r is not a percent, and a strong r alone never proves that one thing causes the other.

techniques

Multiply, then add

A prediction from a fitted line.

  1. Multiply the slope by the x value first.
  2. Then add the starting value.
worked example

Example: A fitted line says cost = 150 + 12.5 × units. What does it predict for cost when units = 8?

  1. 12.5 × 8 = 100.
  2. 150 + 100 = 250.

Answer: 250

Actual minus predicted

A residual.

  1. Put x into the line to get the prediction.
  2. Residual: actual minus predicted.
  3. A negative residual means the line guessed too high.
worked example

Example: A line predicts ŷ = 4 + 3x. At x = 6 the actual y is 19. What is the residual (actual minus predicted)?

  1. Predicted: 4 + 3 × 6 = 22.
  2. Residual: 19 − 22 = −3.

Answer: −3

Slope from r

The slope of the least-squares line (the standard line of best fit), from r and both SDs.

  1. Multiply r by the standard deviation (SD) of y, the thing you predict.
  2. Divide by the SD of x.
  3. The slope has the same sign as r.
worked example

Example: The correlation between x and y is −0.5. The standard deviation of y is 12 and of x is 8. What is the slope of the least-squares line for predicting y from x?

  1. −0.5 × 12 = −6.
  2. −6 ÷ 8 = −0.75.

Answer: −0.75

watch out for

practice

Sign in to try one

Predict from a line

worked example

A fitted line says score = 29 + 3.6 × hours. What does it predict for score when hours = 10?

Answer: 65

  1. 29 + 3.6 × 10 = 29 + 36 = 65.

Residual

worked example

A line predicts ŷ = 17 + 5x. At x = 3 the actual y is 29. What is the residual (actual minus predicted)?

Answer: -3

  1. Predicted: 17 + 5 × 3 = 32.
  2. Residual = actual − predicted = 29 − 32 = −3.

Read a correlation

worked example

Across weeks, the correlation between ad spending and website visits is 0.6. Which statement fits best?

  1. moderate negative linear relationship
  2. very weak positive linear relationship
  3. no relationship
  4. more ad spending causes 60% more visits
  5. moderate positive linear relationship

Answer: moderate positive linear relationship

  1. r = 0.6: the sign is positive (weeks with more ad spending tend to have more visits), and its size is in the middle: a clear but loose straight-line pattern.
  2. That’s a moderate positive linear relationship. Correlation alone doesn’t prove cause, and r is not a percent.

Slope from r

worked example

The correlation between x and y is −0.6. The standard deviation of y is 18 and the standard deviation of x is 14. What is the slope of the least-squares line for predicting y from x? Round to 2 decimal places.

Answer: -0.77

  1. b = r × s_y ÷ s_x = −0.6 × 18 ÷ 14
  2. = −10.8 ÷ 14 ≈ −0.7714, which rounds to −0.77.

Sign in to start