Regression
2026-02-2213 min read

reghdfe in Stata: High-Dimensional Fixed Effects Made Simple

reghdfe absorbs any number of fixed effects without creating dummy variables. Here's the full tutorial โ€” install, syntax, absorb(), cluster(), and singleton handling.

Sytra Team
Research Engineering Team, Sytra AI

Your fixed-effects model is too big for naive dummy coding, and runtime spikes every time you add another FE dimension.

You will run efficient high-dimensional FE models with diagnostics that keep inference credible.

All examples tested in Stata 18 SE. Compatible with Stata 15+.


Quick Answer

  1. Install reghdfe from SSC and verify version.
  2. Specify FE dimensions in absorb(), not manual dummies.
  3. Cluster at the correct design level and check singleton drops.
  4. Store model metadata for replication packages.

Estimate High-Dimensional FE Models with Transparent Diagnostics

Set up and run core reghdfe specifications

reghdfe absorbs fixed effects efficiently without explicit dummy expansion. This keeps memory use manageable in large panel settings.

A minimal robust workflow includes installation check, core model, and clustered standard errors.

If you are extending this pipeline, also review How to Merge Datasets in Stata and How to Structure a Stata Project.

reghdfe-core.do
stata
1clear all
2set obs 4000
3gen firm_id = ceil(_n/20)
4gen worker_id = _n
5gen year = 2010 + mod(_n,10)
6gen education = 8 + floor(runiform()*10)
7gen tenure = floor(runiform()*15)
8gen wage = 9 + 0.7*education + 0.3*tenure + rnormal(0,2)
9
10capture which reghdfe
11if _rc ssc install reghdfe
12
13reghdfe wage education tenure, absorb(firm_id year) vce(cluster firm_id)
. reghdfe wage education tenure, absorb(firm_id year) vce(cluster firm_id)
HDFE Linear regression                            Number of obs   =      4,000
Absorbing 2 HDFE groups                           F(   2,    199) =     412.67
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.6914
                                                  Adj R-squared   =     0.6751
------------------------------------------------------------------------------
        wage | Coefficient  std. err.      t    P>|t|
-------------+----------------------------------------
   education |   .7041182   .0281304    25.03   0.000
      tenure |   .2977448   .0189211    15.74   0.000
------------------------------------------------------------------------------
๐Ÿ’กAbsorb fixed effects, do not generate them
Using absorb() is more stable and faster than creating thousands of FE dummies manually.

Track singleton drops and model support

High-dimensional FE designs can silently lose support if many groups have little within variation. Singleton diagnostics should be part of every run log.

Comparing sample counts across specifications helps catch unintentional design changes.

reghdfe-support-checks.do
stata
1clear all
2set obs 4000
3gen firm_id = ceil(_n/20)
4gen worker_id = _n
5gen year = 2010 + mod(_n,10)
6gen education = 8 + floor(runiform()*10)
7gen tenure = floor(runiform()*15)
8gen wage = 9 + 0.7*education + 0.3*tenure + rnormal(0,2)
9
10capture which reghdfe
11if _rc ssc install reghdfe
12
13reghdfe wage education tenure, absorb(firm_id year) vce(cluster firm_id)
14
15* ---- Section-specific continuation ----
16reghdfe wage education tenure, absorb(firm_id year) vce(cluster firm_id)
17
18* Compare retained sample
19count
20estimates store hdfe_main
21
22reghdfe wage education tenure, absorb(firm_id worker_id year) vce(cluster firm_id)
23count
24estimates store hdfe_plus_worker
25
26estimates table hdfe_main hdfe_plus_worker, b se
. estimates table hdfe_main hdfe_plus_worker, b se
-------------------------------------------------
    Variable |   hdfe_main      hdfe_plus_worker
-------------+-----------------------------------
   education |   0.7041         0.6874
             |  (0.0281)       (0.0318)
      tenure |   0.2977         0.2812
             |  (0.0189)       (0.0204)
-------------------------------------------------
โš ๏ธSample drift is substantive
When added fixed effects drop many observations, coefficient changes may reflect support loss, not pure identification gains.

Common Errors and Fixes

"command reghdfe is unrecognized"

reghdfe is user-written and missing from the current ado path.

Install reghdfe and dependencies via SSC, then verify with which reghdfe.

. reghdfe wage education, absorb(firm_id year)
command reghdfe is unrecognized
r(199);
This causes the error
wrong-way.do
stata
reghdfe wage education, absorb(firm_id year)
This is the fix
right-way.do
stata
ssc install reghdfe
which reghdfe
reghdfe wage education, absorb(firm_id year)
error-fix.do
stata
1capture which reghdfe
2if _rc {
3 ssc install reghdfe
4 ssc install ftools
5}
6which reghdfe
. which reghdfe
c:adoplus

eghdfe.ado
*! version 6.1.3

Command Reference

xtreg (official FE baseline)

Stata docs โ†’

Official fixed-effects estimator in Stata and a baseline comparison for reghdfe workflows.

xtset panelvar timevar ; xtreg y x1 x2, fe vce(cluster panelvar)
feWithin estimator with unit fixed effects
vce(cluster id)Cluster-robust variance estimator
reRandom-effects alternative for comparison tests
hausmanCompares FE and RE assumptions

How Sytra Handles This

Sytra can map research design text into absorb and cluster options, and flag singleton and weak-support issues automatically.

A direct natural-language prompt for this exact workflow:

sytra-prompt.txt
bash
Run a reghdfe wage model with absorb(firm_id year), cluster by firm_id, report singleton drops, compare with a richer absorb set including worker_id, and output side-by-side coefficient table.

Sytra catches these errors before you run.

Sytra can map research design text into absorb and cluster options, and flag singleton and weak-support issues automatically.

Join the Waitlist โ†’

FAQ

When should I use reghdfe instead of xtreg?

Use reghdfe when you need multiple high-dimensional fixed effects, faster absorption, or complex clustering structures.

What are singleton observations in reghdfe?

Singletons are observations that are the only record in a fixed-effect group after absorption. reghdfe may drop them to avoid biased inference.

Do I always cluster with reghdfe?

In most panel applications yes, cluster at the treatment or sampling variation level. Report and justify your clustering unit explicitly.


Written by Sytra Team
Research Engineering Team, Sytra AI

We build practical, reproducible workflows for Stata and R teams working on real empirical research pipelines.

#Stata#reghdfe#Fixed Effects#Econometrics

Enjoyed this article?