Using Robust Standard Errors in Stata OLS Regression for Reliable Inference
A step‑by‑step guide to running OLS regression in Stata, diagnosing heteroskedasticity, and applying robust standard errors to obtain trustworthy coefficient estimates.
22 Oct 2025, 15:30 UTC

Desired outcome
Obtain reliable coefficient estimates from a linear OLS model in Stata, especially when heteroskedasticity is present.
Prerequisites
- Stata installed (version 16.0 or later recommended).
- Access to the command window with user permissions.
- Sample dataset; the built‑in `auto` dataset is used for illustration.
Procedure
- Load the dataset:
sysuse auto - Run the basic OLS regression:
regress price mpg weight - Check for heteroskedasticity with the Breusch‑Pagan test:
– a significant p‑value (<0.05) indicates non‑constant variance.estat breuschpagan - If heteroskedasticity is detected, re‑estimate using robust standard errors:
regress price mpg weight, robust - Compare the coefficient table: conventional SEs versus robust SEs.
Verification and recovery
After estimation, examine the output table for:
- Coefficient signs and significance (t‑stat > 1.96 for 5% level).
- Robust standard errors (displayed in parentheses when `robust` option is used).
- Model fit statistics such as R‑squared and F‑statistic.
If the robust model produces implausible results, consider:
- Re‑checking the Breusch‑Pagan test.
- Inspecting residual plots with
predict residandtwoway (scatter residual mpg). - Fitting a heteroskedasticity‑consistent model such as Huber‑White or clustered SEs.
To revert to the original (non‑robust) specification, simply re‑run the basic regress command without the `robust` option.
Limitations
Robust standard errors assume the correct mean‑value regression model; misspecification of the functional form can still bias estimates. They are not suitable for small samples where the asymptotic theory may not hold. Ensure the dataset meets the linear regression assumptions (linearity, no perfect multicollinearity).
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.