Announcement

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

  • xtivreg2 instrumental variables with endogenous variable involves in interaction terms

    Hi all,

    I'm conducting analysis in the form below:

    Code:
    y = x1 + x2 + x3 + x1*x2
    In which x1 is the variable of interest and it is endogenous. Say I have a valid instrument for x1: namely z1. The data is in panel structure so ivreg2 is used.

    without including the interaction term, I can run the code below successfully:

    Code:
    xtivreg2: y x2 x3 (x1=z1), fe
    But with the interaction term,
    Code:
    xtivreg2: y x2 x3 (x1 c.x1#c.x2 = z1 c.z1#c.x2), fe
    throws an error:
    Code:
    cx1#c:  operator invalid
    I searched online and find a potential remedy here, what it does is:
    Code:
    gen x1x2 = x1*x2
    gen z1x2 = z1*x2
    xtivreg2: y x2 x3 (x1 x1x2 = z1 z1x2), fe
    This works indeed, but I want to know would this affects the consistency and efficiency of the coefficients?
    Or more broadly, what is the shortcoming of this method as compared to one in which I can just run:
    Code:
    xtivreg2: y x2 x3 (x1 c.x1#c.x2 = z1 c.z1#c.x2), fe
    Thanks in advance for all your time and knowledge

  • #2
    An interaction between two continuous variables is just a multiplication of the variables. As the endogenous variables are dependent variables in an initial-stage regression, Stata by convention does not allow dependent variables to be specified as interactions. So you have to create the interaction by hand. Otherwise, I think that this should work:

    Code:
    gen x1x2 = x1*x2
    xtivreg2: y x2 x3 (x1 x1x2 = z1 c.z1#c.x2), fe

    Comment


    • #3
      Thanks for your reply, I tested you suggestion but it ran into the same error as I posted in the beginning.

      Originally posted by Andrew Musau View Post
      An interaction between two continuous variables is just a multiplication of the variables. As the endogenous variables are dependent variables in an initial-stage regression, Stata by convention does not allow dependent variables to be specified as interactions. So you have to create the interaction by hand. Otherwise, I think that this should work:

      Code:
      gen x1x2 = x1*x2
      xtivreg2: y x2 x3 (x1 x1x2 = z1 c.z1#c.x2), fe

      Comment


      • #4
        I did not notice that you were using xtivreg2 (SSC) and not the official Stata command xtivreg. You are supposed to state this (FAQ Advice #12). My comment should hold for xtivreg. In any case, creating the interactions by hand as you do will not change the results assuming you were able to use factor variables (follows from the first sentence in #2).

        Comment


        • #5
          My fault to not make it clear that I'm using xtivreg2, and yes xtivreg takes care of such cases. A quick follow up question, what if I have two instruments, say, z1 and z2 for x1? how should I specify the state command using xtivreg2?
          Originally posted by Andrew Musau View Post
          I did not notice that you were using xtivreg2 (SSC) and not the official Stata command xtivreg. You are supposed to state this (FAQ Advice #12). My comment should hold for xtivreg. In any case, creating the interactions by hand as you do will not change the results assuming you were able to use factor variables (follows from the first sentence in #2).

          Comment


          • #6
            what if I have two instruments, say, z1 and z2 for x1?
            You can specify multiple instruments.

            Code:
            xtivreg2: y x2 x3 (x1 = z1 z2), fe

            Comment


            • #7
              How to deal with the situation below:

              Code:
              xtivreg2: y x2 x3 (x1 x1*x2 = z1 z2 x2*z1 x2*z2), fe
              Question is, would Stata know that z1 and z2 are instruments for x1 while x2*z1 x2*z2 are instruments for x1*x2? Or does that matte in the first place?

              Originally posted by Andrew Musau View Post

              You can specify multiple instruments.

              Code:
              xtivreg2: y x2 x3 (x1 = z1 z2), fe
              Last edited by Jia Gao; 01 Feb 2021, 00:13.

              Comment


              • #8
                No, each first stage regression will have all the instruments specified on the right hand side. Including "irrelevant" variables in the first-stage regressions should not matter for what you are interested in, which is the predicted dependent variables from these regressions.

                Comment

                Working...
                X