Assumptions of linear regression
The Core Assumptions (LINE + No Multicollinearity + Normality)
1. Linearity: True Relationship is Linear
Why this matters: If the true relationship is and we fit , we're forcing a straight line through a cubic—residuals will show patterns, predictions will be biased.
How to check: Plot residuals vs. fitted values. A horizontal band around zero = good. A systematic curve or U-shape = linearity violated (note: a funnel shape signals heteroscedasticity, not nonlinearity—see below).
Fix: Transform predictors (, ), use polynomial regression, or switch to non-linear models (trees, neural nets).
2. Independence: Observations Are Independent
Why this matters: If errors are correlated (e.g., time series: today's temperature predicts tomorrow's), standard errors shrink artificially, making -values too small. You think you have significance, but it's an illusion.
Example of violation: Stock prices, longitudinal data (same person measured over time), spatial data (nearby houses).
How to check: Durbin-Watson test (time series), residual ACF plots. If , independence holds; or = trouble.
Fix: Use generalized least squares (GLS), time-series models (ARIMA), or mixed-effects models.
3. Homoscedasticity: Constant Variance of Errors
Derivation of why it's needed: OLS estimates by minimizing . The variance of is: If (homoscedastic), this simplifies to —clean and computable. If not, is diagonal with varying . Because OLS gives every observation equal weight, it effectively overweights the noisy high-variance points (relative to the optimal GLS weight , which would down-weight them). This makes OLS inefficient and its standard errors wrong.
Why this matters: Heteroscedasticity (non-constant variance) makes confidence intervals and -values untrustworthy. Estimates stay unbiased but inefficient.
Example: Predicting income from education. Low education = tight income range; high education = huge variance (some earn millions, some don't).
How to check: Residuals vs. fitted plot (look for a funnel shape—the tell-tale sign of heteroscedasticity), Breusch-Pagan test, White test.
Fix: Transform (log, square-root), use weighted least squares (WLS) where , or robust standard errors.
4. Normality of Errors (for Inference)
Important distinction:
- For prediction: normality is not required. OLS is still BLUE (Best Linear Unbiased Estimator) by Gauss-Markov.
- For hypothesis tests and confidence intervals: we need normality to use -distributions and -tests. Without it, -values are approximate.
Why this matters: If errors are heavy-tailed (Cauchy, -distribution with df=2), a few outliers dominate , and intervals are too narrow.
How to check: Q-Q plot (quantile-quantile), Shapiro-Wilk test, histogram of residuals.
Fix: With large (>30–50), Central Limit Theorem rescues you—sampling distribution of approaches normal even if is not. For small : transform , use bootstrap inference, or robust regression.
5. No Multicollinearity: Predictors Are Not Perfectly Correlated
Derivation of the problem: OLS solves . If columns of are nearly colinear, has a tiny determinant—nearly singular. Small changes in data cause huge swings in .
Matrix inverse amplifies errors: If , has entries .
Why this matters:
- Coefficients have huge standard errors (wide confidence intervals)
- Signs can flip with minor data changes
- Model becomes uninterpretable: "Is or important?" Both carry the same info, so you can't tell.
Example: Predicting house price with both "area in sq ft" and "area in sq meters". Perfect colinearity: .
How to check:
- Variance Inflation Factor (VIF): , where is from regressing on all other predictors.
- VIF < 5: OK
- VIF > 10: serious multicollinearity
- Correlation matrix heatmap, condition number of .
Fix: Drop one of the corelated predictors, combine them (PCA), or use ridge regression ( penalty shrinks coefficients).
Summary Table
| Assumption | Math | Check | Fix |
|---|---|---|---|
| Linearity | Residual plot (curve/U-shape) | Transform or | |
| Independence | Durbin-Watson, ACF | GLS, time-series model | |
| Homoscedasticity | Residual plot (funnel), Breusch-Pagan | WLS, log transform | |
| Normality | Q-Q plot | CLT (large ), bootstrap | |
| No Multicolinearity | VIF | Drop predictors, ridge |
Recall Feynman Explanation: Explain Like I'm 12
Imagine you're trying to guess how tall kids are based on their age using a ruler (regression line). But this only works if some rules are true:
- Linearity: Height really does grow in a straight-ish pattern with age. If kids suddenly shrink at age 10, your ruler is useless.
- Independence: Each kid's height doesn't affect another's. If twins always match exactly, you're double-counting.
- Homoscedasticity: The "error" in your guess is the same for 5-year-olds and 15-year-olds. If teenagers vary wildly (some tall, some short) but toddlers are all similar, your ruler's confidence is broken.
- Normality: The mistakes you make are random bell-curve errors, not one-sided (always guessing too short).
- No multicollinearity: You're not using "age in years" and "age in months" together—that's the same info twice, confusing the ruler.
Break these rules, and your guesses might be close on average, but your confidence ("I'm 95% sure!") is a lie.
Connections
- Ordinary Least Squares (OLS): OLS is BLUE only if Gauss-Markov assumptions hold (linearity, independence, homoscedasticity). Normality is extra for inference.
- Residual Analysis: Diagnostic plots (residual vs. fitted, Q-Q) directly test these assumptions.
- Weighted Least Squares: Fixes heteroscedasticity by weighting observations inversely to their variance.
- Ridge and Lasso Regression: Ridge handles multicollinearity by shrinking corelated coefficients.
- Generalized Linear Models (GLMs): Relax linearity and normality—allow non-normal errors (Poisson, binomial) and link functions.
- Hypothesis Testing in Regression: -tests and -tests assume normality of errors. Violated? Use permutation tests or bootstrap.
- Bias-Variance Tradeoff: Violations increase variance of (wider uncertainty) but may not bias estimates (OLS is still unbiased under Gauss-Markov).
#flashcards/ai-ml
What are the five core assumptions of linear regression?
Why does homoscedasticity matter for OLS?
What is the mathematical condition for independence of errors?
How do you check for multicollinearity?
Is normality of errors required for OLS estimates to be unbiased?
What does a funnel shape in a residual plot indicate?
What residual-plot pattern indicates nonlinearity (as opposed to heteroscedasticity)?
Why can't you have two predictors and in a regression?
What does a Q-Q plot diagnose?
If errors are independent but not normal, when is inference still valid?
What is the consequence of violating the independence assumption?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, linear regression ek bahut powerful tool hai, lekin ye koi magic wand nahi hai—ye ek "conditional tool" hai. Iska matlab hai ki jab hum fit karte hain, toh hum ek shart rakh rahe hote hain ki data kuch specific rules follow kare. In rules ko hum assumptions kehte hain, aur inko yaad rakhne ka easy tarika hai: LINE—Linearity, Independence, Normality, aur Equal variance (homoscedasticity). Agar ye assumptions tut jaayein, toh aapke predictions unreliable ho jaate hain, confidence intervals jhoot bolne lagte hain, aur hypothesis tests aapko galat direction mein le jaate hain. Socho jaise ek contract ki fine print—use ignore karo toh saari guarantees khatam.
Ab thoda detail mein samjho. Linearity ka matlab hai ki ka expected value predictors ka linear function hona chahiye—agar asli relationship cubic (jaise ) hai aur hum straight line fit kar rahe hain, toh residuals mein pattern dikhega aur predictions biased honge. Independence ka matlab hai ki har observation ka error doosre se independent ho—time series ya same person ke repeated measurements mein ye tut jaata hai, jisse standard errors artificially chhote ho jaate hain aur aapko lagta hai significance hai jabki wo bas illusion hai. Homoscedasticity ka matlab hai errors ki variance sabhi levels par constant ho—agar variance funnel shape mein badhti-ghatti hai (jaise income prediction mein high education par variance zyada), toh OLS inefficient ho jaata hai kyunki wo noisy points ko equal weight deta hai.
Ye sab kyun important hai? Kyunki checking bahut simple hai—bas residuals vs fitted values ka plot banao. Horizontal band around zero matlab sab theek; curve ya U-shape matlab linearity ka problem; aur funnel shape matlab heteroscedasticity. Aur fixes bhi seedhe hain—transform karo (, ), weighted least squares use karo, ya robust standard errors lagao. Bottom line: assumptions ko check karna aapke model ko trustworthy banata hai. Bina inko verify kiye number nikaalna waise hi hai jaise bina foundation ke ghar banana—dikhega sahi, par bharosa nahi kar sakte.