Linear Regression Assumptions, OLS Residuals, and Violations
Statistics & ExperimentsModel answerLast updated
Evaluate linear regression assumptions on 10,000 rows, prove sample residual orthogonality, analyze multicollinearity, and separate bias from standard error issues.
Assume you are evaluating an Ordinary Least Squares (OLS) regression model fit on a dataset containing $n = 10{,}000$ sample records across $k$ predictor attributes (including the constant intercept column).
Provide a rigorous analysis of the mathematical foundations, diagnostic tests, and remedies:
-
Theoretical Assumptions & Geometric Derivation:
- Enumerate the classical Gauss-Markov conditions for OLS estimators.
- Prove mathematically that the estimated residual vector $e$ is orthogonal to the design matrix $X$.
- Clarify why sample orthogonality between $X$ and $e$ holds strictly by construction and does not serve as proof of the exogeneity hypothesis $E[\varepsilon \mid X] = 0$.
-
Unbiasedness vs. Error Covariance:
- Prove mathematically which Gauss-Markov conditions are required to show that $\hat{\beta}$ is unbiased.
- Show why non-constant variance (heteroskedasticity) or serial correlation in the error terms alters the variance matrix of $\hat{\beta}$ without introducing estimation bias.
-
Multicollinearity Analysis:
- Suppose three key feature vectors in $X$ exhibit strong mutual correlation.
- Analyze the impact of this correlation on estimator bias, variance, and standard errors.
- Outline formal diagnostic tools to identify multicollinearity, and describe mitigation techniques tailored to predictive modeling versus causal coefficient inference.
-
Taxonomy of Regression Violations:
- Classify standard modeling issues—such as omitted variable bias, measurement noise in regressors, endogeneity/reverse causality, non-spherical errors, and non-Gaussian error terms—into issues that induce coefficient bias versus issues that only compromise inference and standard errors.
- Specify the standard methodological fix for each violation.
Hints
Hint 1
Express the sample residuals as e = (I - H)y using the projection matrix H = X(X^T X)^{-1}X^T to show orthogonality.
Hint 2
Substitute y = X\beta + \varepsilon into the definition of \hat{\beta} to isolate which conditions drive expectation vs variance.
Hint 3
Differentiate between sample properties that hold by construction (like X^T e = 0) and population properties concerning the unobserved error term \varepsilon.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Gauss-Markov Setup and Orthogonality of Residuals
Consider the standard linear regression model:
$$y = X\beta + \varepsilon$$
where $y \in \mathbb{R}^n$ represents the target vector, $X \in \mathbb{R}^{n \times k}$ is the design matrix containing $k$ linearly independent feature columns (including an intercept column of ones), $\beta \in \mathbb{R}^k$ is the parameter vector, and $n = 10{,}000$.
Gauss-Markov Assumptions
To establish the properties of OLS estimators, we state the core assumptions:
- Linearity in Parameters: The dependent variable is a linear combination of parameters $\beta$ plus an additive error term: $y = X\beta + \varepsilon$.
- Full Rank: $\text{rank}(X) = k$, meaning $X$ has full column rank and $X^\top X$ is non-singular and invertible.
- Strict Exogeneity: $E[\varepsilon \mid X] = 0$. The population error term has zero expected value conditional on all predictors in $X$.
- Spherical Errors: $\text{Var}(\varepsilon \mid X) = \sigma^2 I_n$. This implies:
- Homoskedasticity: $\text{Var}(\varepsilon_i \mid X) = \sigma^2$ for all $i$.
- No Autocorrelation: $\text{Cov}(\varepsilon_i, \varepsilon_j \mid X) = 0$ for all $i \neq j$.
When assumptions 1–4 hold, the Gauss-Markov Theorem states that the OLS estimator $\hat{\beta} = (X^\top X)^{-1}X^\top y$ is the BLUE (Best Linear Unbiased Estimator).
Note on Error Normality: Normality of errors ($\varepsilon \mid X \sim \mathcal{N}(0, \sigma^2 I_n)$) is not a Gauss-Markov requirement. Normality is only needed for exact finite-sample $t$ and $F$ tests. Given $n = 10{,}000$, the Central Limit Theorem applies, making standard asymptotic inference valid even with non-normal error distributions.
Derivation of Residual Orthogonality
OLS estimates coefficients by minimizing the Sum of Squared Residuals (SSR):
$$S(\beta) = (y - X\beta)^\top (y - X\beta)$$
Taking the gradient with respect to $\beta$ and setting it to zero yields the first-order normal equations:
$$\nabla_\beta S(\hat{\beta}) = -2X^\top(y - X\hat{\beta}) = 0$$
Let $e = y - X\hat{\beta}$ represent the vector of sample residuals. Substituting $e$ into the normal equation gives:
$$X^\top e = 0$$
Using the projection matrix $H = X(X^\top X)^{-1}X^\top$ (where $\hat{y} = Hy$ and $e = (I - H)y$):
$$X^\top e = X^\top (I - H)y = X^\top y - X^\top X(X^\top X)^{-1}X^\top y = X^\top y - X^\top y = 0$$
Because $X^\top e = 0$:
- The residual vector $e$ is orthogonal to every column vector in the feature matrix $X$.
- Because $X$ contains a column of ones, $\sum_{i=1}^n e_i = 0$ (the sum and mean of OLS sample residuals equal zero).
- Residuals are orthogonal to predicted values: $\hat{y}^\top e = (X\hat{\beta})^\top e = \hat{\beta}^\top X^\top e = 0$.
Sample Identity vs. Population Assumption
$X^\top e = 0$ is an algebraic identity forced by the mathematical construction of OLS optimization. It holds for any dataset $X$ and $y$, regardless of whether the model is correctly specified.
In contrast, strict exogeneity ($E[\varepsilon \mid X] = 0$) is a theoretical condition regarding the unobserved population disturbance $\varepsilon$. Zero correlation between sample features $X$ and sample residuals $e$ does not prove that predictors are exogenous to omitted population factors.
2. Proof of Unbiasedness and Role of Error Covariance
Expand the OLS estimator formula by substituting $y = X\beta + \varepsilon$:
$$\hat{\beta} = (X^\top X)^{-1}X^\top (X\beta + \varepsilon) = \beta + (X^\top X)^{-1}X^\top \varepsilon$$
Take expectations conditional on $X$:
$$E[\hat{\beta} \mid X] = E\left[\beta + (X^\top X)^{-1}X^\top \varepsilon ;\middle|; X\right] = \beta + (X^\top X)^{-1}X^\top E[\varepsilon \mid X]$$
If strict exogeneity ($E[\varepsilon \mid X] = 0$) holds, then:
$$E[\hat{\beta} \mid X] = \beta$$
Key Insight: This proof requires only Linearity, Full Rank, and Strict Exogeneity. Assumption 4 (Spherical Errors) is not used to prove unbiasedness.
Impact on Estimator Variance
While non-spherical errors do not introduce bias, they break standard variance calculations. Let $\text{Var}(\varepsilon \mid X) = \Omega$, where $\Omega \neq \sigma^2 I_n$:
$$\text{Var}(\hat{\beta} \mid X) = \text{Var}\left((X^\top X)^{-1}X^\top \varepsilon ;\middle|; X\right) = (X^\top X)^{-1}X^\top \Omega X (X^\top X)^{-1}$$
If we mistakenly assume $\Omega = \sigma^2 I_n$, OLS software uses $\sigma^2 (X^\top X)^{-1}$, leading to incorrect standard errors, invalid $p$-values, and flawed confidence intervals.
3. Analysis of Multicollinearity
When three features in $X$ display high mutual correlation:
- Unbiasedness: Coefficient estimates remain unbiased, because high correlation among columns in $X$ does not violate $E[\varepsilon \mid X] = 0$.
- Variance & Standard Errors: Coefficient variance increases sharply. The variance of the estimated coefficient for predictor $j$ is:
$$\text{Var}(\hat{\beta}_j) = \frac{\sigma^2}{SST_j (1 - R_j^2)} = \frac{\sigma^2}{SST_j} \cdot \text{VIF}_j$$
where $SST_j = \sum_{i=1}^n (x_{ij} - \bar{x}_j)^2$, $R_j^2$ comes from regressing feature $x_j$ on all remaining predictors, and $\text{VIF}_j = \frac{1}{1 - R_j^2}$ is the Variance Inflation Factor.
If $R_j^2 = 0.96$, then $\text{VIF}_j = 25$, inflating standard errors by $\sqrt{25} = 5$.
Diagnostic Indicators
- Variance Inflation Factor: $\text{VIF}_j > 5 \text{ to } 10$.
- Condition Number: $\kappa(X) = \frac{\sigma_{\max}}{\sigma_{\min}} > 30$, where $\sigma$ represents singular values of scaled $X$.
- Hypothesis Discrepancies: Overall regression $F$-test is significant, yet individual $t$-tests for correlated variables are insignificant.
- Sensitivity: Coefficients undergo large sign or magnitude changes when minor data adjustments occur.
Remediation Strategies
- For Predictive Tasks: No intervention required. High correlation within the historical space does not harm predictions, provided predictor correlations remain stable in production data.
- For Structural / Causal Inference:
- Perform joint hypothesis testing (e.g., $F$-tests across the correlated feature block) rather than assessing single coefficients.
- Drop redundant control variables that duplicate information without mitigating confounding.
- Apply Ridge Regression ($L_2$ regularization), introducing slight bias to lower coefficient variance.
- For collinearity caused by interaction terms ($x_1 \cdot x_2$) or polynomials ($x_1^2$), mean-center predictors prior to creating interaction terms.
4. Taxonomy of Regression Violations
| Issue / Violation | Biases $\hat{\beta}$? | Corrupts Standard Errors? | Primary Remediation Strategy |
|---|---|---|---|
| Omitted Variable Bias ($\text{Cov}(X_{\text{included}}, X_{\text{omitted}}) \neq 0$) | Yes | Yes | Include omitted confounders; use Panel Fixed Effects or Instrumental Variables (2SLS). |
| Simultaneity / Reverse Causality | Yes | Yes | Instrumental Variables (IV/2SLS) or Vector Autoregressions (VAR). |
| Measurement Noise in Predictors | Yes (Attenuation towards zero) | Yes | Instrumental Variables, repeated measurements, or errors-in-variables models. |
| Functional Form Misspecification | Yes | Yes | Logarithmic/polynomial transformations, splines; diagnose via Ramsey RESET test. |
| Heteroskedasticity | No | Yes | Heteroskedasticity-Consistent (HC3) Robust Standard Errors or Weighted Least Squares (WLS). |
| Autocorrelation / Group Clustering | No (unless combined with lagged $y$) | Yes | Newey-West (HAC) Standard Errors, Cluster-Robust SEs, or Feasible Generalized Least Squares (FGLS). |
| Imperfect Multicollinearity | No | No (SEs valid, but inflated) | Ridge Regression, feature aggregation/PCA, or dropping redundant variables. |
| Non-Normal Errors | No | No (Negligible at $n = 10{,}000$) | No action required due to Central Limit Theorem; use bootstrapping for prediction intervals if distributions display severe skewness. |
Omitted Variable Bias Formula
If the true underlying data-generating process is:
$$y = X_1\beta_1 + X_2\beta_2 + \varepsilon$$
omitting $X_2$ leads to the short regression estimator $\tilde{\beta}_1 = (X_1^\top X_1)^{-1} X_1^\top y$. Taking expected values yields:
$$E[\tilde{\beta}1 \mid X_1, X_2] = \beta_1 + \beta_2 \underbrace{(X_1^\top X_1)^{-1} X_1^\top X_2}{\Gamma}$$
where $\Gamma$ represents the auxiliary regression coefficients of $X_2$ on $X_1$. Unbiasedness holds only if $\beta_2 = 0$ (the omitted variable has zero effect) or $X_1^\top X_2 = 0$ (the omitted variable is uncorrelated with included predictors).