Last we think it might be related to the demeaning process given that only controlling for id (a categorical) actually does not lead to an error. However the first stage F-stat does not get computed.
julia> reg(df_example, @formula(Y ~ (X1 + X2 ~ Z1 + Z2) + id ) )
IV Model
=======================================================================
Number of obs: 20 Degrees of freedom: 4
R2: 0.787 R2 Adjusted: 0.747
F Statistic: 24.7636 p-value: 0.000
First Stage F-stat (KP): NaN First Stage p-val (KP): NaN
=======================================================================
Estimate Std.Error t value Pr(>|t|) Lower 95% Upper 95%
-----------------------------------------------------------------------
id: 2 -0.417303 0.722155 -0.577858 0.571 -1.9482 1.1136
X1 2.95074 0.641615 4.59892 0.000 1.59057 4.3109
X2 3.29365 0.470651 6.99808 0.000 2.29592 4.29139
(Intercept) -0.707435 0.595924 -1.18712 0.253 -1.97074 0.555869
=======================================================================
We are trying to figure out how to get the right first stage F-stat when we have a lot of endogenous regressors and just as many instruments.
Looking at it the issue might be in Vcov.
Digging further we also find that ivreg2 runs into similar trouble computing these statistics.
I have encountered something puzzling while trying to estimate standard errors of a 2SLS regression.
I have tried to include a reproducible example.
Our dataset looks like:
We are interested in an regression of Y on X1 and X2 with instruments Z1 and Z2. We also consider id fixed effects.
For reference we also run the regression without fixed effects which is the only one that seems to work:
Then we run the regression as recommended in the readme:
Last we think it might be related to the demeaning process given that only controlling for
id
(a categorical) actually does not lead to an error. However the first stage F-stat does not get computed.We are trying to figure out how to get the right first stage F-stat when we have a lot of endogenous regressors and just as many instruments. Looking at it the issue might be in Vcov.
Digging further we also find that
ivreg2
runs into similar trouble computing these statistics.