sergiocorreia / ivreghdfe

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

driscoll-kraay standard errors: ivreg2 vs ivreghdfe #16

Closed laciab closed 4 years ago

laciab commented 5 years ago

Consider the following models:

  1. ivreg2 y (x=z) i.cross i.time, dkraay(3) small
  2. ivreg2 y (x=z) i.cross i.time, partial(i.cross i.time) dkraay(3) small
  3. reghdfe y (x=z), absorb(i.cross i.time) vce(cluster time,dkraay(3)) old
  4. ivreghdfe y (x=z), absorb(i.cross i.time) dkraay(3)

I get identical point estimates. Standard errors are however different. In particular, I get m(1) = m(2) ≠ m(3) = m(4)

What am I missing?

TeodoraTsankova commented 4 years ago

I see the same issue when I use either xtivreg2 or ivreghdfe. The latter had the advantage of allowing for factor variables.

Are there any insights as to why this is happening? Thank you!

laciab commented 4 years ago

This issue has been discussed here: https://www.statalist.org/forums/forum/general-stata-discussion/general/1492862-reghdfe-dkraay. The standard errors computed by ivreg2 and reghdfe differ in the way dofs are computed.

Using reghdfe or ivreghdfe, you can replicate ivreg2 by specifying the option dof(none), which assumes that the degrees-of-freedom used by the fixed effects is equal to the count of all the fixed effects.

The default option dof(all), instead, adjusts the count for the presence of redundant fixed effects (i.e. for collinearity across the fixed effects).

IVREG2 dofs

  1. ivreg2 y (x=z) i.cross i.time, dkraay(3) small
  2. ivreg2 y (x=z) i.cross i.time, partial(i.cross i.time) dkraay(3) small
  3. reghdfe y (x=z), absorb(cross time) vce(cluster time,dkraay(3)) old dof(none)
  4. ivreghdfe y (x=z), absorb(cross time) dkraay(3) dof(none)

REGHDFE dofs

  1. reghdfe y (x=z), absorb(cross time) vce(cluster time,dkraay(3)) old
  2. ivreghdfe y (x=z), absorb(cross time) dkraay(3)