Announcement

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

  • Interaction terms and reference categories

    Dear Statalisters,

    I am using Stata's factor variable notation to create interactions:
    glm depvar i.x1##i.x2 i.x1##i.x3 i.x3##i.x4, fam(bin) link(log) difficult eform

    I would like to use a different parametrization to include indicator variables for all reference categories, similar to the output at pag. 2 (model c2) in Stata tip 106: M.L. Buis (2012) "Stata tip 106: With or without reference", The Stata Journal, 12(1), pp. 162-164.
    I tried glm depvar ibn.x1##ibn.x2 i.x1##ibn.x3 i.x3##ibn.x4, fam(bin) link(log) difficult eform
    but some interactions were omitted because of collinearity.
    My question is how to deal with more than one interaction.
    Sincerely
    Giuliana

  • #2
    Errata corrige: I tried glm depvar ibn.x1#ibn.x2 i.x1#ibn.x3 i.x3#ibn.x4, fam(bin) link(log) difficult eform nocons

    Comment


    • #3
      Well, I don't think this can be done. When you are working with just one variable, ibn.x1 produces a bunch of indicator variables that always sum to 1. Since the constant term is also always 1, it is collinear with the constant, and removing the constant from the model with -nocons- eliminates that problem. Hence the combination of ibn. with nocons.

      But if there is also a second variable x2, when you put ibn.x2 into the model, you have brought back the collinearity because now the sum of the x2 indicator variables is, again 1, which is the same as the sum of the x1 indicator variables. So you have collinearity between the x1 and x2 indicators, and there is no more constant term to remove. So you're stuck.

      But assuming that the reason you want this parameterization ins because you would like to have output that shows the expected values in the different categories, I would forget about trying to get that from the coefficients. Running -margins x1 x2 x3 x4- after the glm will get you that.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Well, I don't think this can be done. When you are working with just one variable, ibn.x1 produces a bunch of indicator variables that always sum to 1. Since the constant term is also always 1, it is collinear with the constant, and removing the constant from the model with -nocons- eliminates that problem. Hence the combination of ibn. with nocons.

        But if there is also a second variable x2, when you put ibn.x2 into the model, you have brought back the collinearity because now the sum of the x2 indicator variables is, again 1, which is the same as the sum of the x1 indicator variables. So you have collinearity between the x1 and x2 indicators, and there is no more constant term to remove. So you're stuck.

        But assuming that the reason you want this parameterization ins because you would like to have output that shows the expected values in the different categories, I would forget about trying to get that from the coefficients. Running -margins x1 x2 x3 x4- after the glm will get you that.
        Dear Clyde,
        familiar to your really helpful response: Do you think it could be possible to use the code and still get no baseevels omitted in the interaction?The code:

        regress dependentvariable treatmentvariable##ibn.education $controls, vce(cluster clustervariable) noconstant

        --> Using that code all coefficents for education level 1,2, & 3 are shown. BUT the interactions for educational level 3 are still omitted.
        meaning, I want to heave:
        treat1 x educ 1
        treat1 x educ 2
        treat1 x educ 3

        treat2 x educ 1
        treat2 x educ 2
        treat2 x educ 3

        BUT I get
        treat1 x educ 1
        treat1 x educ 2
        OMITTED

        treat2 x educ 1
        treat2 x educ 2
        OMITTED

        Do you know why that is or how I can work around that Problem?

        Best,Soj

        Comment


        • #5
          Hello,

          i think I figured it out. The problem was the double ##

          Using soley one # solves the problem.

          -> regress health treat#ibn.education $controls, vce(cluster clusterlevel)

          Comment

          Working...
          X