Lecture Notes: Linear Regression
1. Assumptions (Gauss-Markov Theorem)
For OLS to be BLUE (Best Linear Unbiased Estimator):
- Linearity: ( E(Y|X) = X\beta )
- Exogeneity: ( E(\epsilon|X) = 0 )
- Homoscedasticity: ( Var(\epsilon_i|X) = \sigma^2 ) (constant)
- No autocorrelation: ( Cov(\epsilon_i, \epsilon_j|X) = 0 ) for ( i \neq j )
- No perfect multicollinearity: ( X'X ) invertible
For inference (t/F tests): + Normality ( \epsilon \sim N(0, \sigma^2 I) )
Example: Wage ~ Experience. Violate homoscedasticity if high earners have variable residuals.
Exercise 1: Why does perfect multicollinearity bias OLS?
Sol: ( X'X ) singular → no unique ( \hat{\beta} ). Perfect collinearity means redundant predictors.
2. Estimation (OLS)
Model: ( Y = X\beta + \epsilon ), ( n \times 1 ) vector.
Objective: Minimize SSE ( = (Y - X\beta)'(Y - X\beta) ).
Derivation:
[
\frac{\partial \text{SSE}}{\partial \beta} = -2X'(Y - X\beta) = 0 \implies X'X\hat{\beta} = X'Y \implies \hat{\beta} = (X'X)^{-1}X'Y
]
Var((\hat{\beta}) = \sigma^2 (X'X)^{-1} ), est. ( \hat{\sigma}^2 = \frac{\text{SSE}}{n-k} ).
Predictions: ( \hat{Y} = X\hat{\beta} ), residuals ( e = Y - \hat{Y} ).
Example (Simple LR, n=3):
X = [1,1; 1,2; 1,3], Y=[2;3;5]
\hat{\beta} = (X'X)^{-1}X'Y = [0.333; 1.333], \hat{Y}=[1.333;2.667;4]
SSE=0.333, ( R^2 = 1 - \frac{0.333}{4} = 0.917 ).
Exercise 2: Compute OLS for Y=[1,3], X=[1,1;1,2].
Sol: ( \hat{\beta}_0 = -1 ), ( \hat{\beta}_1 = 2 ). Deriv: ( X'X = \begin{bmatrix}2&3\3&5\end{bmatrix} ), inv≈[5,-3;-3,2], X'Y=[4;6] → β=[-1;2].
3. Diagnostics
Check assumptions via residuals ( e_i ).
| Issue | Test/Diagnostic | Remedy |
|---|
| Normality | Q-Q plot, Shapiro-Wilk | Transform Y |
| Heteroscedasticity | Breusch-Pagan, White; residual vs. fitted plot | Robust SE, WLS |
| Autocorrelation | Durbin-Watson (DW~2=good) | Add lags, Newey-West SE |
| Linearity | Residual vs. fitted/partial plots | Polynomials, splines |
| Multicollinearity | VIF>10; cond. #>30 | Drop vars, PCA |
| Outliers/Influence | Cook's D>1; Leverage | Winsorize, robust reg |
Example: DW=1.2 → positive autocorr. (time series).
Exercise 3: Residuals: [-2,0,3]. Suggests? Shapiro p=0.01.
Sol: Non-normal (right skew). Use log(Y) or robust tests.
4. Interpretation
- ( \hat{\beta}_j ): ∂E(Y)/∂X_j (ceteris paribus).
- SE(β_j), t=β_j/SE → p-value.
- Confidence: ( \hat{\beta}j \pm t{n-k,1-\alpha/2} \cdot SE ).
- ( R^2 = 1 - \frac{\text{SSE}}{\text{SST}} ) (% var explained); adj. ( R^2 ) penalizes k.
- F-test: Overall sig. ( H_0: \beta_1=...=\beta_k=0 ).
Example: ( \hat{wage} = 20 + 2 \cdot exp ) (SE_exp=0.5, t=4, p<0.01). +$2/hour per year exp. 95%CI exp: [1,3].
Exercise 4: β=[5, -1.2] (SE=[1,0.4]), n=50,k=2. Interpret β1, test H0:β1=0.
Sol: X1 ↑1 → Y↓1.2 (t=-3, p<0.01 reject). R² not given.
5. Extensions
| Method | When/Why | Key Formula |
|---|
| Ridge | Multicollinearity | ( \hat{\beta} = (X'X + \lambda I)^{-1}X'Y ) |
| Lasso | Var selection | ( \min \text{SSE} + \lambda \sum |
| Robust Reg | Outliers/hetero | Huber/Quantile loss |
| GLM (e.g., Logit) | Non-normal Y | Link g(μ)=Xβ, IRLS est. |
| IV/2SLS | Endogeneity | Instr. Z: 1st stg ( X_1 = Z\pi + v ), 2nd ( Y = \hat{X}_1 \gamma + ... ) |
| Panel FE | Unobs. heterogeneity | ( y_{it} = \alpha_i + X_{it}\beta + \epsilon_{it} ) |
Example: Lasso shrinks noise vars to 0.
Exercise 5: Why use IV for price~demand (endog price)?
Sol: Cost shifters as Z. 2SLS consistent if valid instr. (corr(Z,X), exog Z).
6. Common Pitfalls
- Omitted vars: Bias toward zero/∞ if corr(omit,X)>0.
- Sample selection: Heckman correction.
- P-hacking: Multiple testing → FDR adj.
- Extrapolation: Outside X range.
- Causal vs. assoc: RCTs or good design needed.
- Binary X: Interpret as shift (not slope).
Example Pitfall: Spurious corr (ice cream~crime: summer omitted).
Exercise 6: Omitted confounder Z>0 corr with X,Y. Bias dir?
Sol: Positive (upward). Formula: Bias = γ_{ZY} \cdot \frac{\sigma_{ZX}}{\sigma_X^2} >0.