sergiocorreia / reghdfe

Linear, IV and GMM Regressions With Any Number of Fixed Effects
http://scorreia.com/software/reghdfe/
MIT License
214 stars 56 forks source link

Add weakivtest #171

Open jagorichatterjee opened 5 years ago

jagorichatterjee commented 5 years ago

Will it be possible to add weakivtest after the ivreghdfe command? I have more than one instrument for which the appropriate heteroskedasticity corrected first-stage F statistic seems to be the Montiel Olea and Plueger (2013) and it can be only executed with the weakivtest command after either ivreg2 or ivregress which are very slow (even with Stata MP 4 cores) with the large number of fixed effects (since I cannot use xtivreg to be able to use weakivtest).

sergiocorreia commented 5 years ago

ivreghdfe is currently just a modified version of ivreg2, so it might be possible to do so. I haven't read the original weakiv paper in a while, however, so I don't know if there is anything that theoretically precludes these tests if you are partialling out regressors.

duncanhobbs commented 5 years ago

I tried to run weakivtest after running an example regression from the ivreg2 help file.

ivreg2 lw s expr tenure rns _I* (iq=kww age), cluster(year) partial(_I*)

I got an error Noconstant option is not supported by weakivtest.

In the ivreg2 help file it says:

"partial(varlist) requests that the exogenous regressors in varlist be partialled out from the other variables in the equation. If the equation includes a constant, it is automatically partialled out as well. The coefficients corresponding to the regressors in varlist are not calculated."

Montiel Olea and Pflueger (2013) paper details the derivation of the test statistics.

Stata Journal article describes the how weakivtest command works.

etiennebacher commented 1 year ago

Hello @sergiocorreia and thanks for this amazing package! I'm wondering if there are some plans to add support for weakivtest after ivreghdfe, or is it something that needs to be added in weakivtest instead?

Gkreindler commented 1 year ago

ivreghdfe is currently just a modified version of ivreg2, so it might be possible to do so. I haven't read the original weakiv paper in a while, however, so I don't know if there is anything that theoretically precludes these tests if you are partialling out regressors.

These notes derive the bias from weak instruments and eventually recommend Montiel Olea and Pflueger (2013), and if I am reading this correctly, page 10 here suggests that partialing out regressors would be OK for all this: https://scholar.harvard.edu/files/stock/files/nbersi2018_methods_lectures_weakiv1-2_v4.pdf

I would also find it super helpful to be able to run weakivtest after ivreghdfe, so I wanted to bump up this thread! Many thanks!

felixpoege commented 1 year ago

It's really just a check in weakivtest that is in the way. The cleanest way is to modify your private copy of weakivtest.ado and to add ivreghdfe wherever it checks for ivreg2. Alternatively, you can trick weakivtest into working like this

cap prog drop trick_weakivtest
prog define trick_weakivtest, eclass
    args mycmd
    `mycmd'
    ereturn local cmd = "ivreg2"
    weakivtest
end

sysuse auto
trick_weakivtest "ivreghdfe price (mpg = length)"
yjwang273 commented 1 year ago

@felixpoege This is excellent! But it seems like if I include the "absorb()" in ivreghdfe, weakivtest will automatically do the small sample adjustment. Any advice on fixing this? Thanks a lot!

LuisYep9526 commented 11 months ago

Hi, an update for the "weakivtest" command is available, and it is now compatible with "reghdfe" and "ivreghdfe". To download this new version, you can type "adoupdate weakivtest" or "ssc install weakivtest.

yjwang273 commented 11 months ago

Thank you! I appreciate it very much.

On Wed, Oct 11, 2023 at 06:57 LuisYep9526 @.***> wrote:

Hi, an update for the "weakivtest" command is available, and it is now compatible with "reghdfe" and "ivreghdfe". To download this new version, you can type "adoupdate weakivtest" or "ssc install weakivtest.

— Reply to this email directly, view it on GitHub https://github.com/sergiocorreia/reghdfe/issues/171#issuecomment-1757534738, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYEV5AGQXEMIDU523RKWFRDX62CSPANCNFSM4HAW5HNQ . You are receiving this because you commented.Message ID: @.***>

Tamim-arman commented 7 months ago

I am getting the error “no observations” after using the weakivtest command. I am using stata 17.

mhno commented 5 months ago

I am getting the error “no observations” too. I am using stata 14 in mac!