Announcement

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

  • Categorical interaction terms

    Hi,
    I am a bit lost in terms of how to interpret interaction effects between categorical variables.

    We wanted to look at effects of time and genotype on pain over time. There are 3 time points and 3 genetic variants.

    The code I used in my model is as such:
    xtmixed pain time##genotype || ID:

    the interaction term that results look like this:
    time#genotype
    2 2 | -.040
    2 3 | .566
    3 2 | -1.25
    3 3 | .06

    My question is: what is the reference here? Is it genotype 1 at baseline / genotype 1 at baseline compared to baseline value of genetic variant 2/3 / or something else?
    Some help with this is highly appreciated!

    Thanks in advance
    Ann

  • #2
    Use margins to help with the interpretation. The reference categories are those that are omitted - and the coefficients on the interaction terms reflect differences in the effects of the interacting variable on the outcome between the subgroups. Reference categories in blue below:

    Code:
    webuse productivity, clear
    set seed 05032023
    gen zero1= runiformint(0,1)
    mixed gsp private emp region##zero1 || state:, nolog
    margins region##zero1, post
    di (_b[2.region#1.zero1]- _b[1.region#1.zero1]) - (_b[2.region#0.zero1]- _b[1.region#0.zero1])

    Res.:

    Code:
    . mixed gsp private emp region##zero1 || state:, nolog
    
    Mixed-effects ML regression                     Number of obs     =        816
    Group variable: state                           Number of groups  =         48
    
                                                    Obs per group:
                                                                  min =         17
                                                                  avg =       17.0
                                                                  max =         17
    
                                                    Wald chi2(19)     =   19385.99
    Log likelihood =   1388.234                     Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
             gsp | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         private |   .2296795   .0187202    12.27   0.000     .1929885    .2663704
             emp |   .8029527   .0207391    38.72   0.000     .7623049    .8436005
                 |
          region |
              2  |   .0543114   .0594841     0.91   0.361    -.0622752     .170898
              3  |   .0008312   .0508529     0.02   0.987    -.0988387     .100501
              4  |  -.0014129   .0463764    -0.03   0.976     -.092309    .0894832
              5  |  -.0406748   .0441636    -0.92   0.357    -.1272339    .0458843
              6  |   -.068843   .0528847    -1.30   0.193    -.1724952    .0348091
              7  |   .0905332   .0549163     1.65   0.099    -.0171007    .1981671
              8  |   .0868273   .0458875     1.89   0.058    -.0031106    .1767652
              9  |   .0788121   .0583256     1.35   0.177     -.035504    .1931282
                 |
         1.zero1 |   .0020372   .0078161     0.26   0.794     -.013282    .0173564
                 |
    region#zero1 |
            2 1  |  -.0143782   .0135599    -1.06   0.289     -.040955    .0121987
            3 1  |  -.0033918   .0117368    -0.29   0.773    -.0263955    .0196119
            4 1  |   .0068828   .0107094     0.64   0.520    -.0141072    .0278728
            5 1  |    .006554   .0103847     0.63   0.528    -.0137997    .0269077
            6 1  |  -.0007459   .0124319    -0.06   0.952     -.025112    .0236202
            7 1  |  -.0010905   .0124834    -0.09   0.930    -.0255574    .0233764
            8 1  |  -.0055484   .0103322    -0.54   0.591     -.025799    .0147023
            9 1  |  -.0006522   .0135303    -0.05   0.962     -.027171    .0258666
                 |
           _cons |   2.461668   .0846728    29.07   0.000     2.295712    2.627624
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    state: Identity              |
                      var(_cons) |   .0062466   .0013323      .0041123    .0094885
    -----------------------------+------------------------------------------------
                   var(Residual) |   .0015168   .0000776      .0013721    .0016767
    ------------------------------------------------------------------------------
    LR test vs. linear model: chibar2(01) = 977.15        Prob >= chibar2 = 0.0000
    
    . 
    . margins region##zero1, post
    
    Predictive margins                                         Number of obs = 816
    
    Expression: Linear prediction, fixed portion, predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          region |
              1  |   10.49141   .0339533   308.99   0.000     10.42486    10.55796
              2  |   10.53834   .0480589   219.28   0.000     10.44414    10.63253
              3  |    10.4905   .0367019   285.83   0.000     10.41856    10.56243
              4  |   10.49353   .0305836   343.11   0.000     10.43359    10.55347
              5  |    10.4541   .0283585   368.64   0.000     10.39852    10.50968
              6  |   10.42218   .0398055   261.83   0.000     10.34417     10.5002
              7  |   10.58138   .0406848   260.08   0.000     10.50164    10.66112
              8  |   10.57539   .0299899   352.63   0.000     10.51661    10.63417
              9  |   10.56989   .0464166   227.72   0.000     10.47891    10.66086
                 |
           zero1 |
              0  |   10.50806   .0115784   907.56   0.000     10.48537    10.53076
              1  |   10.50983   .0115694   908.42   0.000     10.48715     10.5325
                 |
    region#zero1 |
            1 0  |   10.49036   .0341951   306.78   0.000     10.42334    10.55738
            1 1  |    10.4924   .0341605   307.15   0.000     10.42545    10.55935
            2 0  |   10.54467   .0484924   217.45   0.000     10.44963    10.63972
            2 1  |   10.53233   .0482675   218.21   0.000     10.43773    10.62694
            3 0  |   10.49119   .0369675   283.80   0.000     10.41874    10.56365
            3 1  |   10.48984   .0369566   283.84   0.000     10.41741    10.56227
            4 0  |   10.48895   .0308038   340.51   0.000     10.42858    10.54932
            4 1  |   10.49787   .0307995   340.84   0.000      10.4375    10.55824
            5 0  |   10.44969   .0285474   366.05   0.000     10.39374    10.50564
            5 1  |   10.45828   .0285791   365.94   0.000     10.40227    10.51429
            6 0  |   10.42152   .0401361   259.65   0.000     10.34285    10.50019
            6 1  |   10.42281   .0400614   260.17   0.000     10.34429    10.50133
            7 0  |    10.5809   .0410393   257.82   0.000     10.50046    10.66133
            7 1  |   10.58184   .0409132   258.64   0.000     10.50165    10.66203
            8 0  |   10.57719   .0302127   350.09   0.000     10.51797    10.63641
            8 1  |   10.57368   .0301478   350.73   0.000     10.51459    10.63277
            9 0  |   10.56918   .0468261   225.71   0.000      10.4774    10.66095
            9 1  |   10.57056   .0466655   226.52   0.000      10.4791    10.66202
    ------------------------------------------------------------------------------
    
    . 
    . di (_b[2.region#1.zero1]- _b[1.region#1.zero1]) - (_b[2.region#0.zero1]- _b[1.region#0.zero1])
    -.01437815
    
    .

    Comment


    • #3
      You can add the baselevel option to xtmixed to show you what the references are.

      My guess would be time=1 and genotype=1, but without your data that is only a guess.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment

      Working...
      X