hanegreefs.com/ statistics II
Home / Chapters / 08
Chapter 08 · Course ch. 4

Correlation and the linear model

Scatterplots, r, least squares, residuals and R².

About 13 min read · Lecture material: HOC 8

Priority labels: ImportantNeutralLess important show where to spend revision time.

Always start with a scatterplotImportant

To describe the link between two quantitative variables, put the explanatory variable (x) on the horizontal axis and the response (y) on the vertical axis. Read four things: direction (up or down), form (straight or curved), strength (tight or loose) and unusual points. Numbers such as r come second; a picture can reveal what they hide.

The correlation coefficientImportant

The Pearson correlation measures the strength and direction of a linear association: the average product of the two z-scores.

Formula
r = Σ z_x z_y / (n − 1) = Σ (xᵢ − x̄)(yᵢ − ȳ) / ( (n − 1) s_x s_y )
PropertyDetail
Range−1 ≤ r ≤ +1; the sign gives the direction
UnitsNone; rescaling x or y (kg to lb) does not change r
Symmetryr(x, y) = r(y, x)
OutliersA single extreme point can push r up or down sharply
ShapeMeasures only linear association; r = 0 does not mean "no relationship"

Use r only when both variables are quantitative, the form is roughly straight and there are no wild outliers. Report it with the plot.

Correlation is not causationNeutral

In observational data a lurking (confounding) variable may drive both x and y. Children's height and reading skill correlate strongly, largely because both grow with age. Only a randomised experiment supports causal wording.

Why graphs matter: Anscombe and friendsImportant

Anscombe's quartet is four small data sets with practically identical means, spreads, correlation (≈ 0.82) and fitted line (ŷ ≈ 3.0 + 0.5x) but entirely different pictures: one honest straight-line cloud, one clear curve, one line wrecked by a single outlier, and one where all x values are equal except for one point. The "Datasaurus dozen" repeats the trick with a dinosaur, a star and concentric circles sharing the same summary statistics. The regression lab below includes these sets so you can see it yourself.

The linear model and least squaresImportant

A fitted line ŷ = b₀ + b₁x predicts y from x. The least-squares line is the one that makes the sum of squared vertical misses, Σ(y − ŷ)², as small as possible.

Formula
b₁ = r · s_y / s_x b₀ = ȳ − b₁ x̄
  • The line always passes through the point (x̄, ȳ).
  • The residual e = y − ŷ is the vertical gap between a point and the line; residuals add to zero.
  • Slope: each extra unit of x goes with b₁ extra units of predicted y (on average).
  • Intercept: the predicted y at x = 0 — often meaningless when x = 0 lies outside the data.
Worked example

Advertising spend and weekly sales

Eight weeks of data: spend x (k€) = 1, 2, 3, 4, 5, 6, 7, 8 and sales y (k€) = 12, 15, 14, 19, 21, 20, 25, 27. We reuse this data set in chapters 9 and 10.

1

Summaries

x̄ = 4.5, s_x = 2.449; ȳ = 19.125, s_y = 5.276; r = 0.967
2

Slope and intercept

b₁ = 0.967 × 5.276/2.449 = 2.083; b₀ = 19.125 − 2.083 × 4.5 = 9.75
3

Prediction and residual

spend 6: ŷ = 9.75 + 2.083 × 6 = 22.25; observed 20 → e = −2.25
Answer

Each additional €1,000 of spend goes with about €2,083 more weekly sales on average. At 6 k€ the model overshoots by 2.25 k€.

Regression to the meanNeutral

In z-score units the line is simply ẑ_y = r · z_x. Because |r| ≤ 1, the prediction sits nearer to ȳ, in SD units, than x sits to x̄: an exceptional x value tends to be paired with a less exceptional y.

R² — how much variation the line explainsImportant

Formula
R² = r² (simple linear regression)

R² is the share of the variance in y accounted for by the model; 1 − R² is what remains in the residuals. In the sales example R² = 0.935: about 94% of the week-to-week variation in sales is tied to spend. Do not confuse r (direction and strength) with R² (explained share). What counts as "high" depends on the field.

Reality checksNeutral

  • Extrapolation: predictions outside the observed x range are speculation; the line may bend or break beyond the data.
  • Non-linear patterns: a curved cloud calls for a transformation or a different model (see chapter 10).
  • Summary data: correlations built on group averages look stronger than the individual-level truth.
  • Multiple regression is previewed in the handbook as a glimpse ahead: several predictors at once, outside this course's depth.

ToolsNeutral

TI-84: store x in L1 and y in L2, draw with STAT PLOT, then STAT ▸ CALC ▸ LinReg (or LinRegTTest, which also gives the slope test of chapter 9). R:

plot(x, y) # always first cor(x, y) fit <- lm(y ~ x) summary(fit) abline(fit)

Key takeaways

  • Plot first; r only describes linear association and is fragile to outliers.
  • b₁ = r·s_y/s_x and the line goes through (x̄, ȳ); residuals sum to zero.
  • R² = r² is the explained share of variance; correlation never proves causation.
Question
Tap or press space to reveal
Answer
Did you know it?

Multiple choice

Ch 08 · Question 1

r = −0.9 indicates…

Why: Strong, negative, linear.
Ch 08 · Question 2

The line of best fit always passes through…

Why: A property of least squares.
Ch 08 · Question 3

If r = 0.6, R² = ?

Why: 0.6² = 0.36.
Ch 08 · Question 4

Slope b₁ = r·s_y/s_x. With r = 0.5, s_y = 10, s_x = 2, b₁ = ?

Why: 0.5·10/2 = 2.5.
Ch 08 · Question 5

A residual is…

Why: Observed minus predicted.
Ch 08 · Question 6

Anscombe's quartet warns that…

Why: Always plot your data.
Ch 08 · Question 7

The intercept is meaningless when…

Why: It extrapolates to x = 0.
Ch 08 · Question 8

High r proves…

Why: Association is not causation.

Exam-style questions

Exam-style · Ch 08

Interpret r = 0.82 between advertising and sales for 12 months and explain why this alone does not justify raising the budget.

Show outline of a full answer
  1. Strong positive linear association; R² ≈ 0.67.
  2. Check scatterplot: linearity, outliers, groups.
  3. Association ≠ causation: seasonality, lurking variables.
  4. Extrapolation and diminishing returns.

Regression playgroundInteractive

Click to add points, load Anscombe's sets and see r, the line, R² and the residual plot update live.