Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • the ivreg2h doesn't work--warning:variables have been centered

    Hi All,

    I tried to run the ivreg2h command in Stata to obtain the Lewbel IVs but failed. Following Lewbel(2012) I ran a version of the code below to estimate an instrumental variables regression model using Stata 17

    ivreg2h ncskew_cmdos SIZE MB LEV ROA RET SIGMA DTURN FIRMAGE ABACC1 (dummy=),small robust fe gen(iv) z()

    where ncskew_cmdos is yvar, SIZE-ABACC1 are xvars and dummy is endogvar. I planed to get the instruments through "gen(iv)"
    But the code failed to work. The error is: "Warning: variables have been centered"
    Click image for larger version

Name:	_20240824113906.png
Views:	1
Size:	49.8 KB
ID:	1762278
    Click image for larger version

Name:	_20240824113927.png
Views:	1
Size:	45.3 KB
ID:	1762279


    What make me confused is that all the vars used for regression were not centered until I run the code(I use "codebook" to check the vars and surprisely find them have been changed after that). It seems that the "ivreg2h" code changes the vars and fails to work?

    By the way, I used "help ivreg2h" and ran the example code in sequence, but the same error "vars have been centered" appeared again. Now I am wondering why the warning appears and how to solve it. Otherwise I am unable to proceed with the next step of work.(ivreghdfe--last estimates not found)

    Any help would be much appreciated.

    Landon Smith


  • #2
    The message about centering was erroneous. A new version of ivreg2h is now available (via ado update ivreg2h) that should work properly, and allow you to save the generated instruments with the gen option. Some additional changes are needed to deal with the fe (fixed-effects models) option but if you are not using that option, it should work as advertised.

    Comment


    • #3
      Thanks for your help. It works nicely now without the fe option.
      Maybe I shall try to find a way to make the fe option available.

      Comment


      • #4
        Landon,
        If you center the y and x variables yourself (ssc desc center) and use them in ivreg2h, it should work without the fe option. I will see about getting the fe option to work without changing the original data.

        Comment


        • #5
          I find something interesting when trying fe option. I use the code in (help inreg2h--" Example using panel data and HAC standard errors.") to test:
          First I center all the vars(center _all), then I have a set of vars which are centered(named c_invest c_ksstock etc.).
          Then I run ivreg2h with and without fe separately. In addition, I use codebook to check the var before and after I use the fe option.
          (What is interesting is that the code which is in help file "ivreg2h invest L(1/2).kstock (mvalue=), fe" doesn't work. It seems that "L(1/2)." can't work in ivreg2h? Alternatively I gen kstock1=L.kstock kstock2=L.kstock1 by myself)
          I have some findings as follow:

          1.fe option and center(center -all) seems to be different. The result of "ivreg2h invest kstock kstock1 kstock2 (mvalue=),fe" and "ivreg2h invest c_kstock c_kstock1 c_kstock2 (mvalue=)" are not the same, no matter before or after the first use of fe.
          2.Using fe option repeatedly doesn't change the result. The change of vars only happens during the first use of fe.
          3.The result of "ivreg2h invest kstock kstock1 kstock2 (mvalue=),fe" and "ivreg2h invest c_kstock c_kstock1 c_kstock2 (mvalue=),fe" seems to be the same?

          I wonder if fe option is not just centralizing. It may centers the vars indeed, but not confined to it. And maybe the Warning is just a tip. The fe option works well all the time(although it always reports warning tips).

          Landon Smith

          Comment


          • #6
            An additional update of ivreg2h (1.1.07) is now posted on SSC. To get this version, ado update ivreg2h, update

            Comment


            • #7
              Thanks Kit, the upgraded ivreg2h work nicely. I notice that the fe option has been taken down, so I center all the vars instead.

              As a fresh hand I'd like to ask another question:

              My regression code is: “reg ncskew_cmdos ncskew τKsi SIZE MB LEV ROA RET SIGMA DTURN ABACC1 FIRMAGE soe i.year i.nindcd i.PROVINCECODE_13”. I use some factor vars to control the Year & Industry & Province FE.
              Now I plan to use ivreg2h. I find that factor vars are not allowed in ivreg2h.
              I'm wondering how to control the Year & Industry & Province FE in ivreg2h.(I have read some articles showing that they control the FE while using IVH) I don't know how to type my code to do this.

              (Now my code is:
              /*
              center ncskew SIZE MB LEV ROA RET SIGMA DTURN FIRMAGE ABACC1 soe ,prefix(z_)

              ivreg2h ncskew_cmdos z_ncskew z_SIZE z_MB z_LEV z_ROA z_RET z_SIGMA z_DTURN z_FIRMAGE z_ABACC1 z_soe (τKsi=),small robust gen(iv)
              */
              It runs nicely without any error. I just wonder if it controls the FE indeed, and if not, how to change it.)

              Thanks!

              Landon Smith

              Comment

              Working...
              X