Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parentheses unbalanced error when using IV #146

Closed
dothyphendot opened this issue Aug 23, 2018 · 14 comments
Closed

parentheses unbalanced error when using IV #146

dothyphendot opened this issue Aug 23, 2018 · 14 comments
Labels

Comments

@dothyphendot
Copy link

Hi Sergio,

With both real data and the auto dataset I get the error parentheses unbalanced when trying to run an IV regression. Please see below. I believe I'm running the latest version of reghdfe and ftools, although I only have Stata 14.2.

Thanks as always for all your hard work,

Dot

. sysuse auto
(1978 Automobile Data)

. reghdfe price weight length, absorb(turn trunk)
(dropped 9 singleton observations)
(MWFE estimator converged in 11 iterations)

HDFE Linear regression Number of obs = 65
Absorbing 2 HDFE groups F( 2, 38) = 12.85
Prob > F = 0.0001
R-squared = 0.6403
Adj R-squared = 0.3942
Within R-sq. = 0.4035
Root MSE = 2254.6288


   price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]

-------------+----------------------------------------------------------------
weight | 5.688144 1.302818 4.37 0.000 3.050727 8.325561
length | -44.21191 57.60797 -0.77 0.448 -160.8332 72.40933
_cons | -2627.673 8851.647 -0.30 0.768 -20546.9 15291.55

Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
turn | 13 0 13 |
trunk | 13 1 12 |
-----------------------------------------------------+

. reghdfe price weight (length = gear), absorb(turn trunk)
parentheses unbalanced
r(132);

. reghdfe, version
Library/Application Support/Stata/ado/plus/r/reghdfe.ado
*! version 5.2.9 06aug2018

Required packages installed?

  • ftools yes

. ftools, version
Library/Application Support/Stata/ado/plus/f/ftools.ado
*! version 2.30.3 02aug2018

Required packages installed?

  • moremata yes

. di c(stata_version)
14.2

. di c(os)
MacOSX

@dothyphendot
Copy link
Author

I should note that if I install the SSC version I don't get the error.

@sergiocorreia
Copy link
Owner

My bad, the error message is not quite clear:

I moved the IV code of reghdfe into ivreghdfe, so you need to install and use that package in order to do IV

(technically, there is no "IV" code, as I was just wrapping ivreg2)

@dothyphendot
Copy link
Author

Ok great. Many thanks indeed. While I'm here, I also note that if I write (at least with the SSC version:

reghdfe price (length = gear) weight, absorb(turn trunk)

I get an error. This is easy to address as a user - but I wondered if it was intentional?

@dothyphendot
Copy link
Author

dothyphendot commented Aug 23, 2018

I now have a different problem with the ivreghdfe.ado file -- Am I being stupid?

cap ado uninstall ivreg2hdfe

. cap ado uninstall ivreghdfe

. cap ssc install ivreg2 // Install ivreg2, the core package


net install ivreghdfe, from(https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/)
checking ivreghdfe consistency and verifying not already installed...
installing into /Users/James/Library/Application Support/Stata/ado/plus/...
installation complete.
 

ivreghdfe price weight (length = gear), absorb(turn trunk)
center not found -- struct ms_vcvorthog contains no such member
(798 lines skipped)
(error occurred while loading ivreghdfe.ado)

@sergiocorreia
Copy link
Owner

About the first thing, it's because I only coded it to expect parenthesis after the other regressors (now it will just do whatever ivreg2 does)

About the second, that's an ivreg2 error. Can you double check that ivreg2 is installed and more importantly up-to-date, and try running a regression with that?

@dothyphendot
Copy link
Author

Thanks again. Turns out I somehow had multiple vintages of ivreg2 installed. Works beautifully now.

@benjaminhyman
Copy link

Hi Dot,

I'm a reghdfe user facing a similar problem, only my error is occurring while loading ivreg2_p.ado. I was just curious what precisely your problem was. Did you have two copies of a file named ivreg2.ado and/or ivreg2_p.ado installed in different system directories? I'm working on a gov server without internet access, so no ssc or netinstall. Any extra information here might be quite helpful.

Thanks,
Ben

@dothyphendot
Copy link
Author

I had ivreg2 files in multiple places, more than two, in my ado directories and so I deleted them all and started over again. Hope this helps.

@Sebastian1612
Copy link

Dear Sergio,

thank you for the very nice package.

I also encountered a problem when trying to estimate IV with regdhfe. I then installed ivregdhfe and everything worked perfect. However, I like to implement three-way clustering, but ivregdhfe only supports two-way clustering because it is based on ivreg2. Is there any possibility to (a) either use IV with regdhfe, so that one can allow for three-way clustering, or (b) extend ivregdhfe to make three-way clustering possible?

Thank you very much,
Sebastian

@sergiocorreia
Copy link
Owner

@Sebastian1612 as a workaround you can always resort to the "old" option of reghdfe, which allows both IV and three way clustering.

Best,
Sergio

@Sebastian1612
Copy link

Thank you very much, but I got the following error message when using the old command with three-way clustering:

(running historical version of reghdfe)
ivreg2 doesn't allow more than two cluster variables

@sergiocorreia
Copy link
Owner

Thank you very much, but I got the following error message when using the old command with three-way clustering:

(running historical version of reghdfe)
ivreg2 doesn't allow more than two cluster variables

You are right; it's sadly not supported. The only alternative would be to implement IV regressions within reghdfe, which is not particularly appealing for obvious reasons, so we're sadly out of luck.

(That said, I'm not aware of many fields were clustering at 3+ levels is common practice, so you might not need to do so)

@AKentMorris
Copy link

AKentMorris commented Nov 27, 2018

I also stumbled across this when I made the most recent update (the new indication of FE is great! Thank you!). It seems that just updating this in the help file would prevent future questions since the current IV example doesn't work.
sysuse auto
reghdfe price weight (length=head), absorb(rep78) // gives error
ivreghdfe price weight (length=head), absorb(rep78) // works like a charm
In the meantime, this example might help folks that having trouble with the old syntax.

@sergiocorreia
Copy link
Owner

Point taken! I have a bit of a backlog in other things, but I definitely need to update the help file and give a more sane error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants