lrberge / fixest

Fixed-effects estimations
https://lrberge.github.io/fixest/
362 stars 59 forks source link

How to estimate IV with a fixed effect but no controls? #391

Closed matthewolckers closed 1 year ago

matthewolckers commented 1 year ago

Thanks for the fantastic package! It's been super helpful.

I am estimating IV models with FE. As you describe in the intro to the package, we should use:

est_iv_fe = feols(y ~ x1 | fe | x_endo_1 + x_endo_2 ~ x_inst_1 + x_inst_2, base)

where x1 is a control variable, fe is a fixed effect, x_endo_1 and x_endo_2 are endogenous variables instrumented by instruments x_inst_1 and x_inst_2.

What if you don't have any control variables besides the fixed effect? i.e. I want to remove x1.

I tried:

est_iv_fe = feols(y ~ | fe | x_endo_1 + x_endo_2 ~ x_inst_1 + x_inst_2, base) , which throws an error,

and

est_iv_fe = feols(y ~ fe | x_endo_1 + x_endo_2 ~ x_inst_1 + x_inst_2, base) , which intreprets fe as a control and includes it in the regression output.

How should I specify the model correctly?

P.S. This question might have a simple answer as I have a pretty low level of experience with R.

matthewolckers commented 1 year ago

I read through the help file of feols and it states:

If you want to estimate a model without exogenous variables, use 1 as a placeholder: e.g. fml = y ~ 1 | x_endo + x_inst.

So I tried:

est_iv_fe = feols(y ~ 1 | fe | x_endo_1 + x_endo_2 ~ x_inst_1 + x_inst_2, base)

and that seems to work.

Is this the correct way to specify the an IV with a fixed effect but no other controls?

lrberge commented 1 year ago

Hi Matthew: this is absolutely correct :-)