Announcement

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

  • IV with interaction gone wrong

    Hi,

    I have the following specification:

    Code:
    ivreg2 grades (treatment treatment#exchange = lottery lottery#exchange) exchange, r
    grades is my outcome. Variable treatment is the endogenous variable and I use variable lottery as an IV for treatment. I want to see the full interaction effects for "exchange" students, so I decided to interact treatment with exchange and instrument it with lottery*exchange.

    I get no results for 1.treatment#1.exchange, it is missing. I get a ranktest error that may be caused by collinearity.
    I don't understand this. Have I done something wrong?


  • #2
    I've always had trouble with this. To force Stata to give the effect you want:

    Code:
    gen treat_exch = treatment*exchange
    gen lott_exch = lottery*exchange
    ivreg2 grades (treatment treat_exch = lottery lott_exch) exchange, r

    Comment


    • #3
      Originally posted by Jeff Wooldridge View Post
      I've always had trouble with this. To force Stata to give the effect you want:

      Code:
      gen treat_exch = treatment*exchange
      gen lott_exch = lottery*exchange
      ivreg2 grades (treatment treat_exch = lottery lott_exch) exchange, r
      Thank you so much, Professor!

      Comment


      • #4
        Originally posted by Jeff Wooldridge View Post
        I've always had trouble with this. To force Stata to give the effect you want:

        Code:
        gen treat_exch = treatment*exchange
        gen lott_exch = lottery*exchange
        ivreg2 grades (treatment treat_exch = lottery lott_exch) exchange, r
        This is the same as assuming the variables are continuous. By default, Stata assumes variables without prefixes constituting an interaction are categorical.

        Code:
        ivreg2 grades (treatment c.treat#c.exch = lottery c.lott#c.exch) exchange, r

        Comment


        • #5
          Andrew: Do you know why Stata can't figure out that three of the four terms are irrelevant even if it treats the variables as categorical? It just seems messy to me.

          Comment


          • #6
            I find that this happens if you specify the main effects and interactions separately. I assume this is a feature of factor variables. However, if you specify the full set, the redundant interactions are dropped. Consider:

            Code:
            sysuse auto, clear
            qui sum length, d
            gen longcar= length > r(p50)
            
            * SEPARATE MAIN EFFECTS AND INTERACTIONS
            regress mpg foreign foreign#longcar longcar, robust
            
            *SPECIFY MAIN EFFECTS AND INTERACTIONS TOGETHER
            regress mpg foreign##longcar, robust
            Res.:

            Code:
            . 
            . * SEPARATE MAIN EFFECTS AND INTERACTIONS
            
            . 
            . regress mpg foreign foreign#longcar longcar, robust
            note: 1.foreign#0b.longcar omitted because of collinearity.
            note: 1.foreign#1.longcar omitted because of collinearity.
            
            Linear regression                               Number of obs     =         74
                                                            F(2, 70)          =          .
                                                            Prob > F          =          .
                                                            R-squared         =     0.4462
                                                            Root MSE          =     4.3969
            
            ---------------------------------------------------------------------------------
                            |               Robust
                        mpg | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            ----------------+----------------------------------------------------------------
                    foreign |   .0178571   1.757307     0.01   0.992    -3.486981    3.522695
                            |
            foreign#longcar |
                Domestic#1  |   .4900794   1.813721     0.27   0.788    -3.127272    4.107431
                 Foreign#0  |          0  (omitted)
                 Foreign#1  |          0  (omitted)
                            |
                    longcar |  -8.142857   1.431271    -5.69   0.000    -10.99744   -5.288278
                      _cons |     25.125   1.019604    24.64   0.000     23.09146    27.15854
            ---------------------------------------------------------------------------------
            
            . 
            . 
            . 
            . *SPECIFY MAIN EFFECTS AND INTERACTIONS TOGETHER
            
            . 
            . regress mpg foreign##longcar, robust
            
            Linear regression                               Number of obs     =         74
                                                            F(2, 70)          =          .
                                                            Prob > F          =          .
                                                            R-squared         =     0.4462
                                                            Root MSE          =     4.3969
            
            ---------------------------------------------------------------------------------
                            |               Robust
                        mpg | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            ----------------+----------------------------------------------------------------
                    foreign |
                   Foreign  |   .0178571   1.757307     0.01   0.992    -3.486981    3.522695
                  1.longcar |  -7.652778   1.114023    -6.87   0.000    -9.874626   -5.430929
                            |
            foreign#longcar |
                 Foreign#1  |  -.4900794   1.813721    -0.27   0.788    -4.107431    3.127272
                            |
                      _cons |     25.125   1.019604    24.64   0.000     23.09146    27.15854
            ---------------------------------------------------------------------------------
            
            .

            Comment


            • #7
              Originally posted by Andrew Musau View Post

              This is the same as assuming the variables are continuous. By default, Stata assumes variables without prefixes constituting an interaction are categorical.

              Code:
              ivreg2 grades (treatment c.treat#c.exch = lottery c.lott#c.exch) exchange, r
              My variables are not continuous though. How should I deal with that? If I put i. prefix, I get the error that I don't have enough instruments for identification.

              Comment


              • #8
                Can you show the results of

                Code:
                tab treat
                tab exchange
                tab lottery
                ?

                For 0/1 indicators, treating them as binary or continuous does not change the results.


                If I put i. prefix, I get the error that I don't have enough instruments for identification
                Note that my suggestion was to prefix the variables with "c." to replicate Jeff's suggestion, not "i.".
                Last edited by Andrew Musau; 17 Apr 2024, 07:41.

                Comment

                Working...
                X