Skip to content
Module 07 of 1265 min readIntermediate

OLS regression and post-estimation

regress, predict residuals, robust standard errors, lincom, test, the post-estimation suite that turns a model into a claim.

58%

Listen along

Read “OLS regression and post-estimation” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Learning objectives

By the end of this module, you should be able to:

  • 01Run OLS with regress, including factor variable notation for categorical predictors
  • 02Apply robust standard errors (HC, cluster) using vce()
  • 03Use the post-estimation suite: predict, test, lincom, margins
  • 04Store and combine estimates with estimates store and esttab for publication tables

regress is Stata's OLS command. The output table is one of the cleanest in any statistical software, and the ecosystem of post-estimation commands (predict, test, lincom, margins) turns a single regression into a structured analytical product.

regress

stata
regress lending_rate deposit_rate
regress lending_rate deposit_rate i.year // with year fixed effects
regress lending_rate c.deposit_rate##i.year // interactions

Robust standard errors

stata
regress lending_rate deposit_rate, robust // HC3
regress lending_rate deposit_rate, vce(cluster bank_id) // clustered
regress lending_rate deposit_rate, vce(robust) cluster(bank_id) // both

Reading the output

  • Source / SS / df / MS — the ANOVA decomposition
  • Number of obs — sample size
  • F(p, n-p-1) — joint test of all coefficients = 0
  • R-squared — fraction of variance explained
  • Root MSE — sqrt of mean squared error
  • Coef. / Std. Err. / t / P>|t| / [95% CI] — per coefficient

Post-estimation: predict, test, lincom

stata
regress lending_rate deposit_rate i.year
predict yhat // fitted values
predict residual, residuals // residuals
predict se, stdp // standard error of fitted value
test deposit_rate // test single coefficient
test 2024.year = 2023.year // test equality
lincom deposit_rate + 2024.year // linear combination with SE

store and esttab — publication tables

stata
regress lending_rate deposit_rate
estimates store m1
regress lending_rate deposit_rate i.year
estimates store m2
estout m1 m2, cells(b(star fmt(3)) se(par fmt(3))) ///
stats(N r2 r2_a, fmt(0 3 3))

regress is one line. The post-estimation is the analysis.

Anyone can run a regression. The discipline of an applied econometrician shows in what they do next: testing constraints, computing margins, comparing specifications, presenting tables. That's where Stata earns its keep.

Exercise

Run a regression of lending_rate on deposit_rate with robust standard errors.

Key takeaways

  • regress y x1 x2 i.year, robust covers 80% of everyday OLS work
  • vce(cluster id) for clustered SEs — required whenever observations within groups are correlated
  • post-estimation is where Stata earns its keep: test, lincom, margins turn coefficients into claims
  • estimates store + esttab produce publication-ready tables in LaTeX, Word, or HTML

Further reading

  1. 01

    Microeconometrics Using Stata (Revised Edition)

    A. Colin Cameron & Pravin K. Trivedi · Stata Press · 2010

  2. 02

    Introductory Econometrics: A Modern Approach (7th Edition)

    Jeffrey M. Wooldridge · Cengage · 2020

  3. 03
Loading progress…
LeadAfrikPublic Economics Hub