Ordinary Least Squares (OLS) Lab
Explore OLS estimation, heteroskedasticity, and omitted-variable bias. Toggle a control variable, switch between classical and robust standard errors, and inspect diagnostics like Residuals vs. Fitted.
Parameters
High correlation + excluding w ⇒ omitted-variable bias in βx.
Standard Errors
Quick Scenarios
OLS fit
1.801
β̂ for x
True βx = 1.20
0.538
R²
Goodness of fit
0.601
Bias (β̂ − β)
No control; corr(x,w) = 0.60
0.135
SE for β̂x
HC1 robust
Residuals vs Fitted
Funnel shape ⇒ heteroskedasticity; curvature ⇒ misspecification (consider adding w).
Stata Implementation
* OLS with HC1 robust SEs
clear all
use "your_data.dta", clear
* Fit model
regress y x, vce(robust)
* Diagnostics
predict yhat, xb
predict e, residuals
rvfplot
* If heteroskedasticity is suspected, prefer robust SEs
* estat hettest // Breusch–Pagan
When do OLS estimates make sense?
Key assumptions:
- Linearity & correct specification (include relevant controls like
w
). - Exogeneity (errors uncorrelated with regressors).
- Homoskedasticity for classical SEs — otherwise prefer robust SEs.
Good practice:
- Report robust SEs when heteroskedasticity is plausible.
- Check residual plots; add controls to address omitted-variable bias.
- Document your model choices and assumptions clearly.