Announcement

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

  • Categorical variable interactions with reghdfe

    Dear all,

    I am running a regression on a categorical variable that takes the value of 0,1,2.

    I want to omit value 1 so I write:

    char categoricalvariable[omit] 1
    xi: reghdfe y i.categoricalvariable, a() vce()

    But when I want to interact with another categorical variable:
    xi: reghdfe y i.categoricalvariable##i.categoricalvariable2, a() vce() , it states "interactions not allowed"

    So I have to run:
    char categoricalvariable[omit] 1
    reghdfe y i.categoricalvariable##i.categoricalvariable2, a() vce()

    But when I do this stata doesn't recognise that I want to omit the value 1, and the value that ends up omitted is 0.

    Does someone know how to solve this?
    Many thanks

  • #2
    Try -fvset base 1 categoricalvariable- instead of -char categoricalvariable[omit] 1-.

    Alternatively, instead of setting the base in the variable, you can specify it in the regression itself
    Code:
    reghdfe y ib1.categoricalvariable##i.categoricalvariable2 ...
    As for the problems you had with -xi-, that is an almost entirely obsolete command. It has been replaced by factor-variable notation almost entirely. There do remain a few commands that do not support factor variable notation and where -xi- can fill that gap. But most of those commands are obscure or archaic, and typically the same analyses can be accomplished with more modern commands that do support factor variable notation. So I urge you to banish -xi- to some dusty corner of the back of your mind. There is a good chance you will never need to use it at all.

    Comment

    Working...
    X