Announcement

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

  • Problem setting base category in interaction term

    Hi everyone,
    I have a question about choosing the base level of a factor variable in an interaction term with main effects only when using xtreg. I presume I'm not the first person to run into this issue, but I cannot find any guidance in the Stata manual or old forum posts to help. The issue occurs when I am trying to set a certain base category in an interaction term. My choice of base category is ignored by Stata. Specifically, I try to set the second category of the variable x2 as base in an interaction of x1 with x2. However, in the output the fourth category of x2 is omitted, instead of the second category being the base, as specified (see below the relevant part of the output):
    Code:
    xtreg y c.x1#ib2.x2 i.year , fe robust allbaselevels 
    
                               |               Robust
                             y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
                       x2#c.x1 |
                            1  |   .8954887   .6693987     1.34   0.189    -.4584979    2.249475
                            2  |   .1291345   .6481673     0.20   0.843    -1.181908    1.440177
                            3  |  -.8268249   .4934912    -1.68   0.102    -1.825005    .1713553
                            4  |          0  (omitted)
                               |
                         year  |
                         1400  |          0  (base)
                         1425  |   .1343599   .1536929     0.87   0.387    -.1765132    .4452331
                         1450  |   .3906657   .2905451     1.34   0.187    -.1970173    .9783487
                         1475  |   1.199689   .4185224     2.87   0.007     .3531474     2.04623
    
    ...
    Any tips would be greatly appreciated.

    Thank you so much
    Felix

  • #2
    you have mis-specified your interaction and, as you can, see, x2 by itself is not shown at all; try
    Code:
     
     xtreg y c.x1##ib2.x2 i.year , fe robust allbaselevels
    that is, include the second # symbol

    Comment


    • #3
      Thank you Rich! I deliberately wanted to have only the main effect, because x1 and x2 alone are absorbed by the unit-fixed effects and the time fixed effects. That is why I specified the interaction term only with one #. Do you think there is a way to make this work with only one #?
      Best,
      Felix

      Comment


      • #4
        This question pops up here from time to time. See https://www.statalist.org/forums/for...nuous-variable

        Comment


        • #5
          re: #3 - I don't think I understand; using just one # means you ONLY get the interaction; if you don't want the interaction, don't use any #'s

          Comment

          Working...
          X