sergiocorreia / ivreghdfe

Run IV/2SLS with many levels of fixed effects (i.e. ivreg2+reghdfe)
MIT License
77 stars 27 forks source link

vce(cluster var) accepted, but ignored. #44

Closed martin-andresen closed 1 year ago

martin-andresen commented 2 years ago

I recently realized that ivreghdfe accepts the vce(cluster clustvar) syntax, but seem to ignore it in my case. Stata/BE 17, ivreghdfe, reghdfe, ftools and ranktest just updated to most recent versions as of today. The MWE below reproduces a simple example of three stacked IV regressions, where vce(cluster id) is accepted, but returns what seems to be conventional standard errors, while cluster(id) works fine. Struggled with this for days!

Thanks a ton for all the great work on coding these up, by the way, and sorry if the mistake is between the chair and the keyboard.

clear all
set obs 100
gen id=_n
gen z=rnormal()
gen D=runiform()<0.3+0.4*z
expand 3
bys id: gen t=_n
gen y=t*D+2+rnormal()+10*rnormal()*(t>2)

ivregress 2sls y (c.D#t=t#c.z) i.t //conventional s.e.'s 
ivreghdfe y (c.D#t=t#c.z), absorb(t) vce(cluster id) //also conventional s.e.'s - vce(cluster id) accepted, but ignored.
ivregress 2sls y (c.D#t=t#c.z) i.t, cluster(id) //clustered s.e.'s 
ivreghdfe y (c.D#t=t#c.z), absorb(t) cluster(id) //also clustered s.e.'s