sergiocorreia / ivreghdfe

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

Issue with ivreghdfe Command in Stata: "option requirements not allowed" #50

Closed alandavidgz closed 1 year ago

alandavidgz commented 1 year ago

I'm currently working with the ivreghdfe command in Stata 18. Unexpectedly, I've started to face the following error, even though the same code and database didn't produce this error just a week ago:

option requirements not allowed r(198);

To troubleshoot, I've updated the ftools, reghdfe, ivreg2, and ivreghdfe packages, but the issue persists.

Has anyone encountered this issue previously or have any insights into potential causes?

Thanks in advance!

WenjieWWJ commented 1 year ago

I face the same issue. Pls let me know if you find a solution. Thanks!

WenjieWWJ commented 1 year ago

I have solved the problem by re-installing the packages. I tried to install based on the commands in the readme.

But the URL is invalid. So I tried to manually install by downloading the packages and installing from local files. Instructions can be found here: http://scorreia.com/software/reghdfe/install.html

After the installation, the error is gone.

mshi311 commented 1 year ago

I am flagging that I am still having this issue with Stata18 even after uninstalling and then installing from local files, as Wenjie suggested.

sergiocorreia commented 1 year ago

Could you list the versions of ivreghdfe and its dependencies installed? (ivreg2 ftools reghdfe)?

Thanks!

alandavidgz commented 1 year ago

I solve it using the original installation code:

mshi311 commented 1 year ago

I downloaded the zip files listed here and installed using net install [PACKAGE], from([SRC-FOLDER-OF-UNZIPPED-FOLDER]).

For ivreg2 I installed using ssc install ivreg2.

I did both of these today on Stata version 18.0 after uninstalling every package.

I'm not quite sure how to tell the version of each package, but here are the distribution dates from the ado describe command: For ivreghdfe the distribution date was 20211214. For ftools the distribution date was 20230820. For reghdfe the distribution date 20230912.

For ivreg2, the distribution date was 20230730.

Thanks!

sergiocorreia commented 1 year ago

It's a bit hard for me to debug the issue with the current information. Some things that could help are:

  1. Run this:
which ftools
which reghdfe
which ivreghdfe
which ivreg2

(The distribution dates listed in ado describe are often not updated)

  1. Note also that you can install directly without downloading the zip file locally. Is there a reason why you did so?

  2. The error option requirements not allowed is the only hint I have. This option existed internally in reghdfe5, so if you are running reghdfe6 then it will not pop up. Maybe to double check what's going on you could use set trace?

sysuse auto
set trace on
set tracedepth 2
<toy ivreghdfe command using the auto dataset>
mshi311 commented 1 year ago

Versions: Ftools: ! version 2.49.1 08aug2023 reghdfe: ! version 6.12.4 12sep2023 ivreghdfe and ivreg2/l ! ivreghdfe 1.0.0 07jul2018 ! this just adds absorb() to this code: ! ivreg2 4.1.10 9Feb2016 ! authors cfb & mes ! see end of file for version comments

I installed directly without downloading the zip at first, and then based on Wenjie's suggestion above I tried using the zip. I've now tried both ways and get the same error code.

The log file from the example with the auto dataset is a bit long so I will include it as the next comment. Edit: copying and pasting the full log file after doing set trace on is a bit clunky so I have just copy and pasted the section that seems to be giving the error below. Please let me know if you would like to see another part of the log file. Thanks!

mshi311 commented 1 year ago
 =  ivreg211 headroom mpg (weight = length), absorb(rep78)
    -------------------------------------------------------------------------------------------------------- begin ivreghdfe.ivreg211 ---
    - version 11.2
    - local ranktestversion 01.3.02
    - local ivreg2cmd "ivreg211"
    - local ivreg2name "ivreg2"
    - local ranktestcmd "ranktest"
    - if replay() {
      syntax [, FIRST FFIRST RF SFIRST dropfirst droprf dropsfirst Level(integer $S_level) NOHEader NOFOoter EForm(string) PLUS NOOMITTED
>  vsquish noemptycells baselevels allbaselevels VERsion ]
      if "`version'" != "" & "`first'`ffirst'`rf'`noheader'`nofooter'`dropfirst'`droprf'`eform'`plus'" != "" {
      di as err "option version not allowed"
      error 198
      }
      if "`version'" != "" {
      di in gr "`lversion'"
      ereturn clear
      ereturn local version `lversion'
      exit
      }
      if `"`e(cmd)'"' != "ivreghdfe" {
      error 301
      }
      local dispopt eform(`eform') `noomitted' `vsquish' `noemptycells' `baselevels' `allbaselevels'
      if "`e(firsteqs)'" != "" & "`dropfirst'" == "" {
      local savefirst "savefirst"
      }
      if "`e(rfeq)'" != "" & "`droprf'" == "" {
      local saverf "saverf"
      }
      if "`e(sfirsteq)'" != "" & "`dropsfirst'" == "" {
      local savesfirst "savesfirst"
      }
      DispCollinDups
      }
    - else {
    - local cmdline `ivreg2name' `0'
    = local cmdline ivreg2 headroom mpg (weight = length), absorb(rep78)
    - checkversion_ranktest `ranktestcmd' `ranktestversion'
    = checkversion_ranktest ranktest 01.3.02
    - syntax [anything(name=0)] [if] [in] [aw fw pw iw/] [, NOID NOCOLLIN FIRST FFIRST SAVEFIRST SAVEFPrefix(name) RF SAVERF SAVERFPrefix
> (name) SFIRST SAVESFIRST SAVESFPrefix(name) SMall NOConstant Robust CLuster(varlist) kiefer dkraay(integer 0) BW(string) kernel(string)
>  center GMM GMM2s CUE LIML COVIV FULLER(real 0) Kclass(real 0) ORTHOG(string) ENDOGtest(string) REDundant(string) PARTIAL(string) FWL(s
> tring) Absorb(string) Level(integer $S_level) NOHEader NOFOoter NOOUTput bvclean NOOMITTED omitted vsquish noemptycells baselevels allb
> aselevels title(string) subtitle(string) DEPname(string) EForm(string) PLUS Tvar(varname) Ivar(varname) B0(string) SMATRIX(string) WMAT
> RIX(string) sw psd0 psda useqr dofminus(integer 0) sdofminus(integer 0) NOPARTIALSMALL fvall fvsep ]
    = syntax [anything(name=0)] [if] [in] [aw fw pw iw/] [, NOID NOCOLLIN FIRST FFIRST SAVEFIRST SAVEFPrefix(name) RF SAVERF SAVERFPrefix
> (name) SFIRST SAVESFIRST SAVESFPrefix(name) SMall NOConstant Robust CLuster(varlist) kiefer dkraay(integer 0) BW(string) kernel(string)
>  center GMM GMM2s CUE LIML COVIV FULLER(real 0) Kclass(real 0) ORTHOG(string) ENDOGtest(string) REDundant(string) PARTIAL(string) FWL(s
> tring) Absorb(string) Level(integer 95) NOHEader NOFOoter NOOUTput bvclean NOOMITTED omitted vsquish noemptycells baselevels allbaselev
> els title(string) subtitle(string) DEPname(string) EForm(string) PLUS Tvar(varname) Ivar(varname) B0(string) SMATRIX(string) WMATRIX(st
> ring) sw psd0 psda useqr dofminus(integer 0) sdofminus(integer 0) NOPARTIALSMALL fvall fvsep ]
    - if (`"`absorb'"' != "") {
    = if (`"rep78"' != "") {
    - capture which reghdfe
    - if c(rc) {
      di as err "Error: must have reghdfe installed"
      di as err "To install, from within Stata type " _c
      loc url "https://github.com/sergiocorreia/reghdfe/raw/version-4/src/"
      di in smcl `"{stata `"net install reghdfe, from(`url')"':net install reghdfe, from(`url')}"'
      exit 601
      }
    - cap reghdfe, requirements
    - if (c(rc)) reghdfe, requirements
option requirements not allowed
      reghdfe, check
      local small small
      local noconstant noconstant
      local nopartialsmall
      } 
sergiocorreia commented 1 year ago

ftools and reghdfe are up to date, but ivreghdfe is version 1.0 (2018) and the latest available version is 1.1.3 (2023). SImilarly, ivreg2 is from 2016 but the latest release is from 2019.

Please check again if problem persists with latest versions, and if so feel free to reopen!

mshi311 commented 1 year ago

@sergiocorreia thanks -- that worked.

Specifically, for anyone who is reading this later with the same issue: I had to go into the folders which have the .ado files and manually delete everything associated with ivreghdfe or ivreg2. These were in two different folders and I used which ivreghdfe and which ivreg2 to figure out where they were. Then after deleting them, I replaced the ivreghdfe files with the files from what Sergio linked above, and reinstalled ivreg2 using ssc install ivreg2.

It's still not clear to me what happened. But for context I got a new computer (Mac Studio 2023, running Ventura) and installed Stata 18.0. I initially tried to install the packages using ssc install for ivreg2 and the instructions here for ftools, reghdfe, and ivreghdfe. But it seems like this was somehow pulling old versions of these packages.