Announcement

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

  • Is there any difference between i.d1##i.d2 and d1 d2 i.d1#i.d2?

    Dear statalist,

    Can I ask a question about what is the difference between i.d1##i.d2 and d1 d2 i.d1#i.d2? I'm running xtreg, d1 and d2 are two dummies, the DV and control variables are all continuous variables (I use x1 x2 x3 here). I tried 2 codes:
    1. xtreg y i.d1##i.d2 x1 x2 x3 i.year, fe vce(robust)
    2. xtreg y d1 d2 i.d1#i.d2 x1 x2 x3 i.year, fe vce(robust)

    From my understanding, these 2 are equivalent, but I get different results.
    So for no.1 the result for the relevant dummies is:
    Code:
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            1.d1 |   .3877818   .2135928     1.82   0.070    -.0310241    .8065876
            1.d2 |   .2719899   .0192595    14.12   0.000     .2342265    .3097533
                 |
           d1#d2 |
            1 1  |  -.2992672   .2683838    -1.12   0.265    -.8255055    .2269712
    And for no.2 is:
    Code:
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              d1 |   .3877818   .2135928     1.82   0.070    -.0310241    .8065876
              d2 |  -.0272773   .2690751    -0.10   0.919    -.5548709    .5003164
                 |
           d1#d2 |
            0 1  |   .2992672   .2683838     1.12   0.265    -.2269712    .8255055
            1 0  |          0  (omitted)
            1 1  |          0  (omitted)
    So I wonder:
    1. why the coefficient for d2 is different in no.1 and 2, and why the interaction term show exactly the opposite sign?
    2. what is the 1 0 and 1 1 in no.2, and why they are omitted?
    2. If I want to put d1, d2 and the interaction term in the same regression, which is right?

  • #2
    Either specification is technically correct. However, from the computational point of view is better to use
    xtreg y i.d1##i.d2 x1 x2 x3 i.year, fe vce(robust)
    or
    xtreg y i.d1 i.d2 i.d1#i.d2 x1 x2 x3 i.year, fe vce(robust)

    The reason why your commands seems to be producing different results is because you are "treating" d1 and d2 both as discrete (i.) and continuous (no i.). This creates an internal conflict which creates the problem that you see.
    Stata creates all possible d1 d2 combinations, and arbitrary drops the collinear ones.
    In other words, the interaction you see in your second specification is not the same interaction as in your first specification.

    HTH

    Comment


    • #3
      Thanks for your clarification! One more question: if there is no interaction at all, just that my IVs are dummies, I do not need i. in front of them, is that right?

      Comment


      • #4
        no, you dont. However, if there is any chance those dummies were created incorrectly, it would be better to keep using "i."

        Comment


        • #5
          I see! Thanks!

          Comment

          Working...
          X