sergiocorreia / ivreghdfe

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

issues with clustering - insufficient observations #36

Closed nikhilklath closed 1 year ago

nikhilklath commented 3 years ago

@sergiocorreia , I needed some advice on clustering while using ivreghdfe.

My code is - ivreghdfe yvar (ever_win = true_treat), absorb(strata gender#batch city#batch yrs_school#batch age#batch mult_apply_hh#batch) vce(cluster unique_id)

I have 78,670 observations with about 42000 distinct unique_ids. The FEs in absorb() amount to about 3000 dummies.

The error I get is insufficient observations. When I remove the vce(cluster) option, the code runs properly. Could you help out with what I must be doing wrong here?

toyokuma commented 2 years ago

Same problem occurred. Is there a way to figure it out? @nikhilklath @sergiocorreia Thx.

sergiocorreia commented 2 years ago

What do you get if you

a) Run ivreghdfe with the keepsingleton option b) Just run the reduced form or the first stage with reghdfe?

I'm asking this because I suspect you might have insufficient observations if there are a lot of singletons.

nikhilklath commented 2 years ago

What I found to work finally was that I unstalled all the packages (ftools, ivreghdfe, reghdfe, ivreg2) and reinstalled all of then from ssc install and not net install. My best guess was that the older version worked well and the more recent version had some change that made at least my code to not work.

toyokuma commented 2 years ago

uninstall and use ssc install to install again works for me too. BTW, I didn't impose ivreghdfe to keep singletons obs. @sergiocorreia

usewei-cell commented 2 years ago

I also have the same issue when using ivreghdfe with the absorb and cluster options; it reports insufficient observations and no singleton. Furthermore, there is no such issue now that the cluster option has been removed.

sergiocorreia commented 1 year ago

Fixed by https://github.com/sergiocorreia/reghdfe/commit/e73880cf55ee6a6d225f35381e0621cc66453adb !