I'm trying to implement the Two-Way Mundlak estimator as per Jeff Wooldridge 2021 on a pooled ols model to get to an equal outcome as a TWFE model.
I try regress and reghdfe as my comparison commands, and I get equal results when I add the unit fixed effect (just a one-way FE) but not when I add the time average. Where am I going wrong?
I'm not 100% sure if it is intended that regress with two-way mundlak becomes the equivalent of the reghdfe (reghdfe and xtreg, fe generate equivalent results but reg is much quicker so I use that here), or if it should be xtreg, re with TWM (which I also tried and it also works for one-way FE but not TWFE)
A couple of notes about my data: T=58 N=~4000. As a panel it is highly unbalanced (some Ns have only 1 T), however, no data is missing. I've seen Correia's note about singletons but I tried both ways and the difference does not affect interpretation in my dataset.
I try regress and reghdfe as my comparison commands, and I get equal results when I add the unit fixed effect (just a one-way FE) but not when I add the time average. Where am I going wrong?
I'm not 100% sure if it is intended that regress with two-way mundlak becomes the equivalent of the reghdfe (reghdfe and xtreg, fe generate equivalent results but reg is much quicker so I use that here), or if it should be xtreg, re with TWM (which I also tried and it also works for one-way FE but not TWFE)
A couple of notes about my data: T=58 N=~4000. As a panel it is highly unbalanced (some Ns have only 1 T), however, no data is missing. I've seen Correia's note about singletons but I tried both ways and the difference does not affect interpretation in my dataset.
Code:
import delimited "dat.csv", delimiter(",") * mean x by district across years (unit mean) egen x_dist_mean = mean(x), by(dist) * mean x across districts by year (time mean) egen x_yr_mean = mean(x), by(yr) *Compare District FE across various approaches - Coefficients are equivalent but errors are higher for Regress regress y x x_dist_mean reghdfe y x, absorb(i.dist) keepsingletons *Compare TWFE across approaches - regress is out by quite a bit regress y x x_dist_mean x_yr_mean reghdfe y x, absorb(i.dist i.yr) keepsingletons
Comment