Statistics Quest

Simple linear regression (least squares)

The least-squares line ŷ = b₀ + b₁x predicts a quantitative response from one predictor by minimising the sum of squared residuals.

b1=SxySxx=r sysx,b0=yˉ−b1xˉb_1 = \frac{S_{xy}}{S_{xx}} = r\,\frac{s_y}{s_x},\qquad b_0 = \ybar - b_1\xbar
Least-squares slope and intercept
b1b_1
slope: estimated change in mean y per one-unit increase in x
b0b_0
intercept: predicted y when x = 0
Sxy, SxxS_{xy},\ S_{xx}
∑(xi−xˉ)(yi−yˉ)\sum(x_i-\xbar)(y_i-\ybar) and ∑(xi−xˉ)2\sum(x_i-\xbar)^2
r, sx, syr,\ s_x,\ s_y
correlation and sample standard deviations
y^i=b0+b1xi,ei=yi−y^i,minimise ∑ei2\hat y_i = b_0 + b_1 x_i,\qquad e_i = y_i - \hat y_i,\qquad \text{minimise } \sum e_i^2
Fitted values and residuals
y^i\hat y_i
fitted (predicted) value for observation i
eie_i
residual: observed minus fitted

When to use

  • Describing and predicting a quantitative response y from one quantitative predictor x when the scatter plot looks roughly linear.

Assumptions

For description, none beyond a sensible straight-line pattern. For inference (tests, intervals) the LINE conditions: Linear mean, Independent errors, Normal errors, Equal variance — see residual diagnostics.

How to interpret

  • Slope in context: "each additional unit of x is associated with an average change of b1b_1 units in y."
  • Intercept only matters when x = 0 is meaningful and inside the data range.
  • The line always passes through (xˉ,yˉ)(\xbar, \ybar) and the residuals sum to 0.

Common mistakes

  • Extrapolating far outside the observed x range.
  • Reading the slope causally from observational data.
  • Swapping x and y: regressing x on y gives a different line (unless ∣r∣=1|r| = 1).
  • Fitting a line to a clearly curved pattern; check the residual plot.

Example

x = 1, 2, 3, 4, 5, 6 (spend), y = 3, 5, 4, 7, 8, 9 (sales).

  • xˉ=3.5\xbar = 3.5, yˉ=6\ybar = 6, Sxy=21S_{xy} = 21, Sxx=17.5S_{xx} = 17.5, so b1=1.2b_1 = 1.2 and b0=6−1.2×3.5=1.8b_0 = 6 - 1.2 \times 3.5 = 1.8.
  • y^=1.8+1.2x\hat y = 1.8 + 1.2x: each extra thousand SAR of spend goes with 1.2 more units of sales on average. At x = 4 the prediction is 6.6.
  • Residuals: 0, 0.8, −1.4, 0.4, 0.2, 0 (they sum to 0).