Linear Regression Assumptions and Handling Correlated Predictors
Statistics & ExperimentsModel answerLast updated
Describe the classical assumptions behind least squares, explain how correlated predictors affect inference, and cover diagnostics, fixes and the exactly collinear case.
You are fitting an ordinary least squares model and need to reason about when it can be trusted. Answer the following.
- Assumptions. List the classical assumptions behind OLS (linearity, independent errors, constant error variance, normal errors for inference, no exact linear dependence among predictors, correct model specification). For each one, say what it guarantees and what goes wrong when it fails.
- Correlated predictors. Define multicollinearity. Explain how it affects coefficient variance, coefficient stability, confidence intervals and p-values, and clarify what it does not affect (bias of the point estimates).
- Diagnosis. Describe how you would detect it: correlation matrix, variance inflation factors and their usual cutoffs, condition number, and eigenvalue analysis.
- Remedies. Propose ways to deal with it (more data, dropping or merging features, centering for polynomial and interaction terms, ridge, LASSO, elastic net, PCA or PLS) and discuss the trade-offs of each.
- Exact collinearity. If two predictors are perfectly collinear, what happens to X'X, and how do common software packages respond?
Hints
Hint 1
Organize the assumptions in layers: which ones give unbiasedness, which add the minimum-variance property (Gauss-Markov), and which only matter for exact t and F tests.
Hint 2
Write the variance of a single coefficient in terms of the R-squared obtained by regressing that predictor on all the others. The variance inflation factor falls straight out of it.
Hint 3
A pairwise correlation matrix can miss dependencies among three or more variables, so pair it with VIF and with the singular values or eigenvalues of the standardized design matrix.
Hint 4
For the perfect-collinearity case, think about the rank of X, whether the inverse exists, and what a pseudo-inverse, a dropped column, or a penalty does to the solution.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model and setup
The model is y = Xβ + ε, where X is n × p (intercept included) and the estimator is β̂ = (X'X)⁻¹X'y.
1) Assumptions, layered
| Assumption | Meaning | If violated |
|---|---|---|
| Linearity in parameters | E[y given X] = Xβ. Transforms such as x² or log x are fine. | Systematic bias: the wrong function is being fit. |
| Correct specification / exogeneity | E[ε given X] = 0: no omitted confounders, no simultaneity, no measurement error in X. | Bias and inconsistency. Omitting z that correlates with x shifts the x coefficient by roughly β_z · Cov(x,z)/Var(x). |
| Independent errors | Cov(εᵢ, εⱼ) = 0 for i ≠ j. | Estimates remain unbiased, but standard errors are wrong (typically too small under positive autocorrelation). Use HAC or cluster-robust errors, or model the dependence. |
| Constant variance | Var(εᵢ) = σ². | Unbiased but not efficient, and the usual standard errors are invalid. Use heteroscedasticity-robust errors or WLS. |
| No exact collinearity | rank(X) = p. | β is not identified (see part 5). |
| Normal errors | ε ~ N(0, σ²I). | Exact small-sample t and F tests fail. With large n the CLT makes inference approximately fine. Not needed for unbiasedness or Gauss-Markov. |
The layering interviewers want to hear:
- Linearity, exogeneity and full rank give unbiasedness.
- Adding independent, constant-variance errors gives Gauss-Markov: OLS is BLUE with Var(β̂) = σ²(X'X)⁻¹.
- Adding normality gives exact finite-sample inference.
2) What multicollinearity does
Multicollinearity means a predictor is nearly, but not exactly, a linear combination of the others.
For coefficient j:
Var(β̂ⱼ) = σ² / [(n−1)·Var(xⱼ)] × 1 / (1 − Rⱼ²)
where Rⱼ² comes from regressing xⱼ on the other predictors. The last factor is the VIF. As Rⱼ² approaches 1, the variance explodes.
Consequences:
- Standard errors grow by √VIF, and confidence intervals widen by the same factor.
- Instability. Adding or dropping a few rows or a column can swing coefficients wildly or flip signs, because X'X is ill-conditioned.
- p-values rise: individual t-tests become insignificant while the overall F-test and R² remain strong ("the model is significant but no variable is").
- No bias. The estimator stays unbiased and BLUE. The damage is to precision and interpretability.
- Prediction is mostly fine if new data share the same correlation structure, and it degrades when that structure changes.
3) Diagnosis
- Correlation matrix. Pairwise |r| above about 0.8 is a warning. It cannot see dependencies involving three or more variables (e.g. x₃ ≈ x₁ + x₂ with modest pairwise correlations).
- VIF. VIFⱼ = 1/(1 − Rⱼ²). Rough cutoffs: above 5 is worrying, above 10 serious (Rⱼ² > 0.9). Ignore the intercept's VIF.
- Eigenvalues. Standardize columns, then eigendecompose Z'Z. A near-zero eigenvalue λₖ means the eigenvector vₖ is a near-null combination of predictors. Var(β̂) = σ² Σ vₖvₖ'/λₖ, so small λ gives huge variance in that direction.
- Condition number. κ = √(λmax/λmin) = ratio of the extreme singular values of the scaled design. Belsley's guideline: 10 to 30 is moderate, above 30 is strong. Variance-decomposition proportions show which coefficients load on the problematic direction. Always scale first, otherwise κ just reflects units.
import numpy as np, pandas as pd
import statsmodels.api as sm
from statsmodels.stats.outliers_influence import variance_inflation_factor
def collinearity_report(X: pd.DataFrame):
Xc = sm.add_constant(X)
vif = pd.Series(
[variance_inflation_factor(Xc.values, i) for i in range(1, Xc.shape[1])],
index=X.columns)
Z = (X - X.mean()) / X.std(ddof=0)
s = np.linalg.svd(Z.values, compute_uv=False)
return vif, s.max() / s.min(), s**2
4) Remedies and trade-offs
- More data. Variance falls with n and with spread in xⱼ, but only if the new rows break the correlation (e.g. through designed variation). Structural duplicates such as cm and inches never go away.
- Drop a feature. Simple and cuts variance, but risks omitted-variable bias if the feature truly matters.
- Combine features (average, index, ratio). Stabilizes estimates but you can no longer separate individual effects.
- Centering before building x² or x·z terms removes "non-essential" collinearity. Fitted values and the top-order coefficient are unchanged, lower-order coefficients now mean "effect at the mean". It does nothing for genuine correlation between distinct variables.
- Ridge. β̂ = (X'X + λI)⁻¹X'y. It shrinks each singular direction by d²/(d²+λ), damping exactly the unstable directions, and always yields a unique solution. Cost: bias, invalid classical p-values, and a need to standardize and tune λ by cross-validation.
- LASSO. Gives sparse, selected models, but among correlated predictors it picks one somewhat arbitrarily, and the choice changes across resamples.
- Elastic net. Mixes L1 and L2, keeping sparsity while correlated features enter together. Cost: two hyperparameters.
- PCR. Regress on the top principal components. Removes near-null directions but loses interpretability, and since it is unsupervised, a discarded low-variance component may be the predictive one.
- PLS. Chooses components to maximize covariance with y, so it is more target-aware, at the cost of more complexity and less clean theory.
Choose by goal: if you need inference on specific coefficients, prefer merging or dropping features, or gathering better data. If you need prediction, ridge or elastic net is usually the best default.
5) Perfect collinearity
If one column is an exact linear combination of others, rank(X) < p, so X'X is singular (determinant zero, at least one zero eigenvalue) and cannot be inverted. The normal equations have infinitely many solutions: you can add any multiple of the null-space vector to β without changing fitted values. Individual coefficients are not identified, though predictions are.
Typical software behavior:
- R's
lmdrops an aliased column and reportsNAfor its coefficient. - statsmodels uses a pseudo-inverse by default, returning the minimum-norm solution and warning about a singular matrix or huge condition number.
- Other libraries may raise a singular-matrix error, or use a pivoted QR or SVD.
- Ridge works regardless, since X'X + λI is positive definite.
The classic cause is the dummy-variable trap: including an intercept plus a dummy for every category. Fix it by dropping one level, or by removing the intercept.
Common mistakes
- Claiming multicollinearity biases coefficients (it inflates variance only).
- Relying only on pairwise correlations.
- Computing the condition number without scaling.
- Interpreting ridge or LASSO coefficients with classical p-values.
- Treating normality as required for unbiasedness.