Announcement

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

  • Interaction after -mepoisson-

    Hi Statalisters

    I am finalizing analyses in a project where a cross-level interaction is of interest. I am wondering whether my -margins- specification and interpretation is correct. I have searched quite extensively without finding any definite recommendations, and since there is so much expertise on this forum, I hope I might get some help here.

    I have a binary outcome and a binary exposure at individual level and a five-level categorical variable at country level. Since the outcome is common, I am using -mepoisson- to obtain risk ratios:
    Code:
     mepoisson poorhlth i.fdiff##i.welfareregime immstat i.parentSES || country: fdiff, irr
    After testing that there is support for an interaction effect, I examine the interaction with:
    Code:
    . margins fdiff##welfareregime, vsquish
    
    Predictive margins                              Number of obs     =     28,637
    Model VCE    : Robust
    
    Expression   : Marginal predicted mean, predict()
    
    ----------------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------------+----------------------------------------------------------------
                     fdiff |
                       No  |   .3047144   .0136302    22.36   0.000     .2779997    .3314291
                      Yes  |   .4587111    .013653    33.60   0.000     .4319518    .4854705
             welfareregime |
             Scandinavian  |   .2455998   .0172017    14.28   0.000     .2118851    .2793145
              Bismarckian  |   .3221907   .0265032    12.16   0.000     .2702453    .3741361
              Anglo-Saxon  |   .2606679   .0113356    23.00   0.000     .2384505    .2828854
         Eastern-European  |   .3893255   .0144292    26.98   0.000     .3610448    .4176062
        Southern-European  |   .3972321   .0348144    11.41   0.000     .3289972    .4654671
       fdiff#welfareregime |
          No#Scandinavian  |    .218395   .0165498    13.20   0.000      .185958    .2508319
           No#Bismarckian  |   .3023092   .0275353    10.98   0.000      .248341    .3562773
           No#Anglo-Saxon  |   .2326351   .0107442    21.65   0.000     .2115769    .2536933
      No#Eastern-European  |   .3603786   .0135944    26.51   0.000     .3337341    .3870231
     No#Southern-European  |   .3715952   .0312916    11.88   0.000     .3102648    .4329257
         Yes#Scandinavian  |   .3931677   .0209561    18.76   0.000     .3520945    .4342408
          Yes#Bismarckian  |   .4300347   .0237197    18.13   0.000      .383545    .4765243
          Yes#Anglo-Saxon  |   .4127271   .0149689    27.57   0.000     .3833887    .4420656
     Yes#Eastern-European  |    .546343   .0232894    23.46   0.000     .5006966    .5919895
    Yes#Southern-European  |   .5362952   .0539636     9.94   0.000     .4305285    .6420618
    ----------------------------------------------------------------------------------------
    I interpret this table as giving me the predicted probabilities of the outcome, conditional on included covariates in the model (I should perhaps include the -atmeans- options). I further examine the interaction to get at what I consider the main interaction results that I will report:
    Code:
    . contrast [email protected], nowald effects
    
    Contrasts of marginal linear predictions
    
    Margins      : asbalanced
    
    ---------------------------------------------------------------------------------------------------------
                                            |   Contrast   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ----------------------------------------+----------------------------------------------------------------
    poorhlth                                |
                        welfareregime@fdiff |
         (Bismarckian vs Scandinavian) Yes  |   .0896297    .079263     1.13   0.258     -.065723    .2449823
         (Anglo-Saxon vs Scandinavian) Yes  |   .0485506   .0637509     0.76   0.446    -.0763989       .1735
    (Eastern-European vs Scandinavian) Yes  |   .3290109    .068269     4.82   0.000     .1952061    .4628156
       (Southern-European vs Scandinavian)  |
                                       Yes  |   .3104486   .1128225     2.75   0.006     .0893206    .5315765
    ---------------------------------------------------------------------------------------------------------
    I interpret this the following way (using the third row as an example): The group with value 1 on the exposure ("Yes") in Eastern-European countries have a 33 percent increased probability of the outcome (in relative terms), compared to the group with value 1 on the exposure in Scandinavian countries.

    I have two questions:
    1. Is the margins specification correct? I am somewhat unsure as I have a binary outcome and I am not using a logistic model. Specifically, I wonder whether the "marginal prediction mean"/"marginal linear prediction" expression is suitable.
    2. Given a correct specification, is my interpretation correct?





  • #2
    1. No, this is average number of events. While poisson post estimation allows direct prediction of probabilities, mepoisson does not, so you have to do it by hand.

    Here is an example of computing the probability of 1 or 2 events:

    Code:
    webuse epilepsy,clear
    qui mepoisson seiz i.treat##i.v4
    margins treat##v4, expression(exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) )) ///
     + exp(-predict(mu)) *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) )))
     
    qui poisson seiz i.treat##i.v4
    margins treat##v4, predict(pr(1,2))

    Comment


    • #3
      Thanks - I was not aware of this and your code is helpful!

      I tried it and got:
      Code:
      . qui mepoisson poorhlth i.fdiff##i.welfareregime immstat i.parentSES || country: fdiff, irr 
      
      . margins fdiff##welfareregime, expression(exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),
      > 1) )) ///
      >  + exp(-predict(mu)) *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) )))
      
      Predictive margins                              Number of obs     =     28,637
      Model VCE    : Robust
      
      Expression   : exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) )) + exp(-predict(mu))
                     *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) ))
      
      ----------------------------------------------------------------------------------------
                             |            Delta-method
                             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------------+----------------------------------------------------------------
                       fdiff |
                         No  |   .2576958   .0095334    27.03   0.000     .2390107     .276381
                        Yes  |   .3549775   .0076711    46.27   0.000     .3399425    .3700125
                             |
               welfareregime |
               Scandinavian  |   .2137394    .012965    16.49   0.000     .1883286    .2391503
                Bismarckian  |   .2699717   .0182973    14.75   0.000     .2341097    .3058338
                Anglo-Saxon  |   .2249525    .008356    26.92   0.000      .208575      .24133
           Eastern-European  |   .3129789   .0089186    35.09   0.000     .2954988     .330459
          Southern-European  |   .3183357   .0211484    15.05   0.000     .2768855    .3597859
                             |
         fdiff#welfareregime |
            No#Scandinavian  |   .1946863   .0129813    15.00   0.000     .1692434    .2201291
             No#Bismarckian  |   .2571567   .0194077    13.25   0.000     .2191183     .295195
             No#Anglo-Saxon  |   .2057585   .0082711    24.88   0.000     .1895474    .2219695
        No#Eastern-European  |   .2965414   .0088738    33.42   0.000      .279149    .3139337
       No#Southern-European  |   .3037948   .0200864    15.12   0.000     .2644263    .3431634
           Yes#Scandinavian  |   .3174277   .0130389    24.34   0.000     .2918718    .3429835
            Yes#Bismarckian  |   .3397714   .0140064    24.26   0.000     .3123193    .3672235
            Yes#Anglo-Saxon  |   .3294308    .009036    36.46   0.000     .3117206     .347141
       Yes#Eastern-European  |   .4026287    .011457    35.14   0.000     .3801735     .425084
      Yes#Southern-European  |   .3976426   .0270137    14.72   0.000     .3446967    .4505885
      ----------------------------------------------------------------------------------------
      Which should now be interpreted as the probability of the outcome. However, the contrast command gives the exact same results as before and I am not able to use the -expression()- option either. Do you know a way around this?

      Comment


      • #4
        There is a -contrast- option with margins:


        Code:
        . margins treat##v4, expression(exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) )) ///
        >  + exp(-predict(mu)) *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) )))  contrast(effect nowald)
        
        Contrasts of predictive margins                 Number of obs     =        236
        Model VCE    : OIM
        
        Expression   : exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) )) + exp(-predict(mu)) *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) ))
        
        ------------------------------------------------------------------------------------------
                                 |            Delta-method
                                 |   Contrast   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------------------+----------------------------------------------------------------
                           treat |
                    (1 vs base)  |   .0303371   .0324726     0.93   0.350     -.033308    .0939822
                                 |
                              v4 |
                    (1 vs base)  |    .026124   .0187234     1.40   0.163    -.0105732    .0628211
                                 |
                        treat#v4 |
        (1 vs base) (1 vs base)  |   .0406019   .0343547     1.18   0.237    -.0267322    .1079359
        ------------------------------------------------------------------------------------------

        Comment


        • #5
          Great - that was super helpful! To be on the sure side on interpretation:
          Code:
          . margins [email protected], expression(exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1
          > )),1) )) ///
          > + exp(-predict(mu)) *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) )))  contrast(effect nowald)
          
          Contrasts of predictive margins                 Number of obs     =     28,637
          Model VCE    : Robust
          
          Expression   : exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) )) + exp(-predict(mu))
                         *((predict(mu)^2)/(round(exp(lnfactorial(2)),1) ))
          
          ---------------------------------------------------------------------------------------------------------
                                                  |            Delta-method
                                                  |   Contrast   Std. Err.      z    P>|z|     [95% Conf. Interval]
          ----------------------------------------+----------------------------------------------------------------
                              welfareregime@fdiff |
               (Bismarckian vs Scandinavian) Yes  |   .0223437   .0197668     1.13   0.258    -.0163985    .0610859
               (Anglo-Saxon vs Scandinavian) Yes  |   .0120031   .0156989     0.76   0.445    -.0187661    .0427724
          (Eastern-European vs Scandinavian) Yes  |   .0852011   .0173679     4.91   0.000     .0511606    .1192415
             (Southern-European vs Scandinavian)  |
                                             Yes  |   .0802149   .0297297     2.70   0.007     .0219458    .1384841
          ---------------------------------------------------------------------------------------------------------
          As I now obtain predicted probabilities, I can interpret e.g. Eastern-European vs Scandinavian*Yes as an 8% increased probability of the outcome in the Eastern-European group compared to the Scandinavian group, right? Secondary, could you point me to a reference on the calculation? Would like to become more informed about the steps involved.

          Comment


          • #6
            I think it would an increase of 8 percentage points for 1 or 2 events. Looking at the previous table it looks like the probabilities are 32% and 40, so I guess you could state it as a 25% increase in the probability ((40-32)/32).

            The probability was calculated using the probability mass function: https://en.wikipedia.org/wiki/Poisson_distribution

            You might want 1 - Prob(x=0), as the probability of at least 1 event.

            Comment


            • #7
              Thanks, and yes, having the probability of only one event is actually key (repeated events won't make sense in this data structure).

              Is the above calculations for 1 or 2 events? I am working on understanding the coding now, but I can't see where this is included in the expression, and how I may edit this to only one event? I would be very glad if you could point to how I may edit this to obtain the correct estimates.


              Comment


              • #8
                It is Pr(1<= X <=2). The terms after the plus sign is the probability for 2 events.

                Pr(X = k) = (mu ^ k ) * exp(-mu) / k! ; for k = 0, 1, 2, ... and mu predicted rate.
                Pr(X = 1) = (mu ) * exp(-mu)

                In the example I excluded the "^1" and "round(exp(lnfactorial(1)),1)" == 1! == 1 terms just for completeness.
                Code:
                exp(-predict(mu)) *((predict(mu)^1)/(round(exp(lnfactorial(1)),1) ))
                
                which simplifies to:
                
                exp(-predict(mu)) *(predict(mu)

                Comment


                • #9
                  Nice - by this post I grasped the Stata code version of the PMF. Thanks for your help!

                  Comment


                  • #10
                    Dear Scott

                    Your input has been very helpful. I have one final question that would round up this analysis for me, and it's basically a question on whether the interpretation of the interaction term in the main output is correct:
                    Code:
                    . mepoisson poorhlth i.fdiff##i.welfareregime immstat i.parent_SES || country: fdiff, irr
                    
                    ----------------------------------------------------------------------------------------
                                           |               Robust
                                  poorhlth |        IRR   Std. Err.      z    P>|z|     [95% Conf. Interval]
                    -----------------------+----------------------------------------------------------------
                                     fdiff |
                                      Yes  |    1.80026    .044292    23.90   0.000     1.715509    1.889197
                                           |
                             welfareregime |
                              Bismarckian  |   1.384231   .1661129     2.71   0.007     1.094111    1.751282
                              Anglo-Saxon  |   1.065204   .0952808     0.71   0.480     .8939104     1.26932
                         Eastern-European  |   1.650123   .1395431     5.92   0.000     1.398087    1.947594
                        Southern-European  |   1.701483    .190368     4.75   0.000     1.366445    2.118669
                                           |
                       fdiff#welfareregime |
                          Yes#Bismarckian  |   .7901636   .0460396    -4.04   0.000     .7048893    .8857539
                          Yes#Anglo-Saxon  |   .9854909   .0277211    -0.52   0.603     .9326291    1.041349
                     Yes#Eastern-European  |   .8421147   .0324354    -4.46   0.000     .7808828     .908148
                    Yes#Southern-European  |   .8016754   .0236465    -7.49   0.000     .7566433    .8493877
                    Following Buuis comments in this Statalist post, my interpretation is that the effect of the binary exposure fdiff increases risk of outcome with 1.80, and taking the Bismarckian category of the five-level variable welfareregime as an example, the interpretation of the interaction is as follows:

                    The effect of fdiff on outcome is reduced by .79 in the Bismarckian group relative to the reference group, which corresponds to a (0.79-1)*100 = -21 % decrease. Consequently, the risk of outcome among those exposed to fdiff in Bismarckian group is -21% lower compared to those exposed to fdiff in the reference group of the welfareregime variable.

                    Hopefully you could give some final input on this.

                    Comment


                    • #11
                      Tarjei W. Havneraas . No I don't think this is correct. When fdiff = 1 & Bismarckian = 1 then you need the coefficients from fdiff, welfare, and the interaction. But in your case, even this is incomplete since you have fdiff as a random slope component. You will need to use -margins- to get the correct values.

                      Code:
                      webuse epilepsy, clear
                      //make data similar to example 
                      replace seiz = 0 if seiz > 4
                      replace seiz = 1 if seiz>=4
                      recode visit (-.3= 0) (-.1 =1) (.1 = 2 ) (.3 =3)
                      rename (treat visit) (fdiff welfare)
                      label define welfare 0 "Scandinavian" 1 "Bismarck" 2 "Anglo-Saxon" 3 "Eastern" 
                      label values welfare welfare
                      
                      //Simple case
                      quietly mepoisson seizures i.fdiff##i.welfare,irr 
                      margins , at(fdiff =( 1) welfare = (0 1)) vsquish
                      // fdiff = 1 & welfare = 1 Bismarck
                      lincom _b[1.fdiff] +   _b[1.welfare]  +  _b[1.fdiff#1.welfare] +_b[_cons], irr
                      // fdiff = 1 & welfare = 0 Scandinavian
                      lincom _b[1.fdiff]  + _b[_cons], irr
                      
                      //With random components
                      quietly mepoisson seizures i.fdiff##i.welfare ||subject: fdiff, irr  startgrid tech(dfp 5 bfgs 5)
                      margins, at(fdiff =( 1) welfare = (0(1)3)) vsquish
                      
                      margins [email protected], vsquish  contrast(nowald)
                      Because these are contrasts you don't need the "-1" (it gets drops (margin_1 - 1) - (margin_2 - 1) = margin_1 - margin_2). I think you can interpret these directly as Bismarck, relative to Scandinavian, -4%; Anglo-Saxon -15%, Eastern -11%.

                      Code:
                      . margins [email protected], vsquish  contrast(nowald)
                      
                      Contrasts of adjusted predictions               Number of obs     =        236
                      Model VCE    : OIM
                      
                      Expression   : Marginal predicted mean, predict()
                      
                      ----------------------------------------------------------------------------------
                                                       |            Delta-method
                                                       |   Contrast   Std. Err.     [95% Conf. Interval]
                      ---------------------------------+------------------------------------------------
                                         welfare@fdiff |
                         (Bismarck vs Scandinavian) 1  |  -.0370988   .2640394     -.5546065    .4804089
                      (Anglo-Saxon vs Scandinavian) 1  |  -.1479733   .2580859     -.6538123    .3578658
                          (Eastern vs Scandinavian) 1  |     -.1109   .2598381     -.6201734    .3983734
                      ----------------------------------------------------------------------------------

                      Comment


                      • #12
                        Scott Merryman Sorry for a delayed response. I just want to say that this was excellent help. The last post also solved the interaction issue I brought up. Thank you for your input on this topic.

                        Comment

                        Working...
                        X