Announcement

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

  • xtivreg works fine but xtivreg2 gives an error

    Hi all,

    I have a problem which has bogged me down for a few days. when I use:

    xtivreg2 roawrds co2equivalentemissionstotalavg3 (lfreq_ca_news=lnews_iv) lcompanymarketcap yr1-yr11, fe vce(robust)

    I get an error that says "_co2equivalentemissionstotalavg3_m invalid name". What is "_co2equivalentemissionstotalavg3_m"? I do not even have such a variable!

    If I use xtivreg instead of xtivreg2, the code runs fine without an error. Can anyone help please?

  • #2
    xtivreg2 is from SSC (FAQ Advice #12). It is apparent that the command internally creates a variable named


    Code:
    `var'_m
    so that your variable "co2equivalentemissionstotalavg3" becomes "co2equivalentemissionstotalavg3_m". With those variable name lengths, you are probably violating Stata variable name length limits.


    Code:
    rename (co2equivalentemissionstotalavg3 lcompanymarketcap) (co2eqavg3 lcmktcap)
    xtivreg2 roawrds co2eqavg3 (lfreq_ca_news=lnews_iv) lcmktcap yr1-yr11, fe vce(robust)
    Use variable labels if you want to include detailed information about a variable.


    Code:
    help label

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      xtivreg2 is from SSC (FAQ Advice #12). It is apparent that the command internally creates a variable named


      Code:
      `var'_m
      so that your variable "co2equivalentemissionstotalavg3" becomes "co2equivalentemissionstotalavg3_m". With those variable name lengths, you are probably violating Stata variable name length limits.


      Code:
      rename (co2equivalentemissionstotalavg3 lcompanymarketcap) (co2eqavg3 lcmktcap)
      xtivreg2 roawrds co2eqavg3 (lfreq_ca_news=lnews_iv) lcmktcap yr1-yr11, fe vce(robust)
      Use variable labels if you want to include detailed information about a variable.


      Code:
      help label
      Thank you so much for the reply. It fixed that error, but popped up another one. When I use xtivreg2, it removes the IV (lnews_iv) due to collinearity and tells: "equation not identified; must have at least as many instruments not in the regression as there are instrumented variables". Do you have any idea why xtivreg does not remove the IV due to collinearity issue but xtivreg2 does? Is it more sensitive?

      Comment


      • #4
        Show the exact commands that you ran, i.e., both for xtivreg and xtivreg2 and the resulting Stata output. Post this within CODE delimiters.

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Show the exact commands that you ran, i.e., both for xtivreg and xtivreg2 and the resulting Stata output. Post this within CODE delimiters.
          I got the same error, and want some help.
          Two commands:
          xtivreg2 Theil (Epu = lotherepu) $kongzhi_var dyear13-dyear24, fe first savefp(first)
          xtivreg Thei (Epu = lotherepu) $kongzhi_var i.year, fe first
          when I use xtivreg2, it remind me that "Warning - collinearities detected
          Vars dropped: lotherepu
          equation not identified; must have at least as many instruments
          not in the regression as there are instrumented variables
          r(481);
          "
          but xtivreg works well.

          Comment


          • #6
            Likely, the instrument is collinear with the year dummies. If you install ivreghdfe from https://github.com/sergiocorreia/ivreghdfe and absorb the unit and year dummies, this will confirm whether my assertion is correct. Here, it is safer to use the -xi- prefix to avoid any errors with generating the year dummies.

            Code:
            xtivreg Thei (Epu = lotherepu) $kongzhi_var i.year, fe first
            xi: xtivreg2 Thei (Epu = lotherepu) $kongzhi_var i.year, fe first

            Comment

            Working...
            X