Simple Linear Regression
One line, two parameters, and the most widely used predictive model in statistics — fitting a straight line through data to describe how one variable drives another.
The Model
- β₀ — intercept (Y when X = 0)
- β₁ — slope (change in Y per unit X)
- ε — random error (irreducible noise)
Least Squares
A residual is the vertical gap between an observed point and the fitted line: eᵢ = yᵢ − ŷᵢ. Ordinary Least Squares (OLS) finds the line that minimizes the total squared gap.
OLS Estimators
Reading Coefficients
β₀ = $50k: baseline cost
β₁ = $120 per sq ft: marginal value of space
The intercept is meaningful only if X = 0 is in the data range. The slope is always interpretable: a one-unit increase in X predicts a β₁ change in Y.
R² — Variance Explained
Residual Analysis
- Linearity — residuals show no pattern vs. X
- Normality — residuals roughly bell-shaped (QQ plot)
- Homoscedasticity — variance constant across X
- Independence — no autocorrelation in residuals
Homoscedasticity
Violation = heteroscedasticity: spread of residuals fans out or funnels as X grows. Standard errors become unreliable.
Detect with a residuals vs. fitted-values plot. Fix with log transforms or robust standard errors.
Prediction vs. Confidence
A confidence interval bounds the true mean response at X = x*. A prediction interval bounds a new individual observation — always wider because it adds irreducible ε variance.
Slope Significance
H₀: β₁ = 0 (X has no linear effect). Reject if |t| > t₋₍ᴰ₎ₓ(n−2). A significant slope means X is a useful linear predictor of Y.
What you learned
- Model: Y = β₀ + β₁X + ε — line plus noise
- OLS minimizes ∑(yᵢ − ŷᵢ)² to find β̂₀ and β̂₁
- β₁ = slope: unit change in Y per unit X
- R² measures fraction of Y variance explained by X
- Check residuals for linearity, normality, homoscedasticity
- Prediction intervals > confidence intervals — add ε noise
- t-test on β₁ checks whether X is a useful predictor