Announcement

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

  • Getting listcoef to display marginal effects for cross categorical comparison after mlogit

    Hello everyone,

    I'm working with a multinomial logit model with three possible outcomes and clustered standard errors. My goal is to obtain the marginal effects at mean for a cross categorical comparison. After running mlogit, I used mchange, atmeans from the SPost13 package to obtain the marginal effects at mean. I thought subsequently running listcoef , help pvalue(.1) would give me the cross categorical comparison with the coefficients of the MEMs. Apparently I was wrong. listcoef , help pvalue(.1) just displays the cross categorical comparison from the mlogit using it's coefficients and not the MEM ones. Any ideas on how to get a cross categorcial comparison including the MEMs?

  • #2
    Does margins, pwcompare give you what you want? For example

    Code:
    webuse nhanes2f, clear
    quietly mlogit health weight age height
    margins
    margins, pwcompare
    
    . margins
    
    Predictive margins                              Number of obs     =     10,335
    Model VCE    : OIM
    
    1._predict   : Pr(health==poor), predict(pr outcome(1))
    2._predict   : Pr(health==fair), predict(pr outcome(2))
    3._predict   : Pr(health==average), predict(pr outcome(3))
    4._predict   : Pr(health==good), predict(pr outcome(4))
    5._predict   : Pr(health==excellent), predict(pr outcome(5))
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        _predict |
              1  |    .070537   .0024645    28.62   0.000     .0657067    .0753674
              2  |   .1615868   .0035162    45.95   0.000     .1546951    .1684785
              3  |   .2842767   .0044195    64.32   0.000     .2756147    .2929388
              4  |   .2507015   .0042205    59.40   0.000     .2424295    .2589735
              5  |   .2328979   .0040155    58.00   0.000     .2250276    .2407682
    ------------------------------------------------------------------------------
    
    . margins, pwcompare
    
    Pairwise comparisons of predictive margins
    Model VCE    : OIM
    
    1._predict   : Pr(health==poor), predict(pr outcome(1))
    2._predict   : Pr(health==fair), predict(pr outcome(2))
    3._predict   : Pr(health==average), predict(pr outcome(3))
    4._predict   : Pr(health==good), predict(pr outcome(4))
    5._predict   : Pr(health==excellent), predict(pr outcome(5))
    
    --------------------------------------------------------------
                 |            Delta-method         Unadjusted
                 |   Contrast   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
        _predict |
         2 vs 1  |   .0910498    .004636      .0819633    .1001363
         3 vs 1  |   .2137397   .0054505      .2030569    .2244225
         4 vs 1  |   .1801645   .0051669      .1700375    .1902914
         5 vs 1  |   .1623609   .0049374      .1526838     .172038
         3 vs 2  |   .1226899   .0064246      .1100979    .1352818
         4 vs 2  |   .0891147    .006082      .0771942    .1010351
         5 vs 2  |   .0713111   .0058282      .0598881    .0827341
         4 vs 3  |  -.0335752   .0071302     -.0475502   -.0196002
         5 vs 3  |  -.0513788   .0069096     -.0649215   -.0378362
         5 vs 4  |  -.0178036   .0068148     -.0311603   -.0044468
    --------------------------------------------------------------

    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Dear Richard,

      thank you for your suggestion. However, I am afraid that this is not exactly what I am after. I'm interested in getting listcoef, help pvalue(.01) to display the MEM instead of the coeffients of the mlogit which it does now (or to do something else to enable cross-categorical comparisons using the MEMs).



      Code:
      . webuse nhanes2f, clear
      
      .
      . mlogit health weight age height
      
      Iteration 0:   log likelihood = -15764.397 
      Iteration 1:   log likelihood = -14948.196 
      Iteration 2:   log likelihood = -14908.508 
      Iteration 3:   log likelihood =  -14908.18 
      Iteration 4:   log likelihood = -14908.179 
      
      Multinomial logistic regression                 Number of obs     =     10,335
                                                      LR chi2(12)       =    1712.44
                                                      Prob > chi2       =     0.0000
      Log likelihood = -14908.179                     Pseudo R2         =     0.0543
      
      ------------------------------------------------------------------------------
            health |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      poor         |
            weight |   .0050543    .003102     1.63   0.103    -.0010255     .011134
               age |   .0496011    .003269    15.17   0.000     .0431939    .0560082
            height |   .0043417   .0050761     0.86   0.392    -.0056073    .0142907
             _cons |  -5.217091   .8226843    -6.34   0.000    -6.829523   -3.604659
      -------------+----------------------------------------------------------------
      fair         |
            weight |   .0074132   .0022395     3.31   0.001     .0030238    .0118026
               age |   .0279478   .0020718    13.49   0.000     .0238873    .0320084
            height |  -.0110006   .0037503    -2.93   0.003     -.018351   -.0036502
             _cons |  -.7533259   .5979496    -1.26   0.208    -1.925286    .4186337
      -------------+----------------------------------------------------------------
      average      |  (base outcome)
      -------------+----------------------------------------------------------------
      good         |
            weight |  -.0053888    .002043    -2.64   0.008     -.009393   -.0013847
               age |  -.0181946   .0016593   -10.97   0.000    -.0214466   -.0149425
            height |   .0163555   .0033477     4.89   0.000     .0097941    .0229169
             _cons |  -1.636976   .5244043    -3.12   0.002    -2.664789   -.6091622
      -------------+----------------------------------------------------------------
      excellent    |
            weight |  -.0135704   .0021938    -6.19   0.000    -.0178702   -.0092705
               age |  -.0283615   .0017416   -16.28   0.000    -.0317749   -.0249481
            height |   .0357709   .0035283    10.14   0.000     .0288555    .0426863
             _cons |  -3.984935   .5485795    -7.26   0.000    -5.060131   -2.909739
      ------------------------------------------------------------------------------
      
      .
      . mchange, atmeans
      
      mlogit: Changes in Pr(y) | Number of obs = 10335
      
      Expression: Pr(health), predict(outcome())
      
                   |      poor       fair    average       good  excellent
      -------------+-------------------------------------------------------
      weight       |                                                      
                +1 |     0.000      0.002      0.001     -0.001     -0.002
           p-value |     0.003      0.000      0.006      0.075      0.000
               +SD |     0.007      0.025      0.013     -0.011     -0.034
           p-value |     0.007      0.000      0.015      0.039      0.000
          Marginal |     0.000      0.002      0.001     -0.001     -0.002
           p-value |     0.003      0.000      0.006      0.078      0.000
      age          |                                                      
                +1 |     0.003      0.005      0.001     -0.004     -0.005
           p-value |     0.000      0.000      0.000      0.000      0.000
               +SD |     0.071      0.090     -0.001     -0.072     -0.088
           p-value |     0.000      0.000      0.818      0.000      0.000
          Marginal |     0.003      0.005      0.001     -0.004     -0.005
           p-value |     0.000      0.000      0.000      0.000      0.000
      height       |                                                      
                +1 |    -0.000     -0.003     -0.003      0.001      0.006
           p-value |     0.130      0.000      0.000      0.012      0.000
               +SD |    -0.004     -0.030     -0.034      0.011      0.057
           p-value |     0.070      0.000      0.000      0.051      0.000
          Marginal |    -0.000     -0.003     -0.003      0.001      0.006
           p-value |     0.139      0.000      0.000      0.010      0.000
      
      Predictions at base value
      
                   |      poor       fair    average       good  excellent
      -------------+-------------------------------------------------------
        Pr(y|base) |     0.053      0.148      0.308      0.266      0.225
      
      Base values of regressors
      
                   |    weight        age     height
      -------------+---------------------------------
                at |      71.9       47.6        168
      
      1: Estimates with margins option atmeans.
      
      . listcoef, help pvalue(.01)
      
      mlogit (N=10335): Factor change in the odds of health (P<0.01)
      
      Variable: weight (sd=15.356)
      ------------------------------------------------------------------------------
                                   |         b        z    P>|z|       e^b   e^bStdX
      -----------------------------+------------------------------------------------
      poor         vs good         |    0.0104    3.249    0.001     1.010     1.174
      poor         vs excellent    |    0.0186    5.593    0.000     1.019     1.331
      fair         vs average      |    0.0074    3.310    0.001     1.007     1.121
      fair         vs good         |    0.0128    5.376    0.000     1.013     1.217
      fair         vs excellent    |    0.0210    8.284    0.000     1.021     1.380
      average      vs fair         |   -0.0074   -3.310    0.001     0.993     0.892
      average      vs good         |    0.0054    2.638    0.008     1.005     1.086
      average      vs excellent    |    0.0136    6.186    0.000     1.014     1.232
      good         vs poor         |   -0.0104   -3.249    0.001     0.990     0.852
      good         vs fair         |   -0.0128   -5.376    0.000     0.987     0.822
      good         vs average      |   -0.0054   -2.638    0.008     0.995     0.921
      good         vs excellent    |    0.0082    3.648    0.000     1.008     1.134
      excellent    vs poor         |   -0.0186   -5.593    0.000     0.982     0.751
      excellent    vs fair         |   -0.0210   -8.284    0.000     0.979     0.725
      excellent    vs average      |   -0.0136   -6.186    0.000     0.987     0.812
      excellent    vs good         |   -0.0082   -3.648    0.000     0.992     0.882
      ------------------------------------------------------------------------------
      
      Variable: age (sd=17.218)
      ------------------------------------------------------------------------------
                                   |         b        z    P>|z|       e^b   e^bStdX
      -----------------------------+------------------------------------------------
      poor         vs fair         |    0.0217    6.205    0.000     1.022     1.452
      poor         vs average      |    0.0496   15.173    0.000     1.051     2.349
      poor         vs good         |    0.0678   20.443    0.000     1.070     3.213
      poor         vs excellent    |    0.0780   23.156    0.000     1.081     3.828
      fair         vs poor         |   -0.0217   -6.205    0.000     0.979     0.689
      fair         vs average      |    0.0279   13.490    0.000     1.028     1.618
      fair         vs good         |    0.0461   21.612    0.000     1.047     2.213
      fair         vs excellent    |    0.0563   25.488    0.000     1.058     2.637
      average      vs poor         |   -0.0496  -15.173    0.000     0.952     0.426
      average      vs fair         |   -0.0279  -13.490    0.000     0.972     0.618
      average      vs good         |    0.0182   10.966    0.000     1.018     1.368
      average      vs excellent    |    0.0284   16.285    0.000     1.029     1.630
      good         vs poor         |   -0.0678  -20.443    0.000     0.934     0.311
      good         vs fair         |   -0.0461  -21.612    0.000     0.955     0.452
      good         vs average      |   -0.0182  -10.966    0.000     0.982     0.731
      good         vs excellent    |    0.0102    5.739    0.000     1.010     1.191
      excellent    vs poor         |   -0.0780  -23.156    0.000     0.925     0.261
      excellent    vs fair         |   -0.0563  -25.488    0.000     0.945     0.379
      excellent    vs average      |   -0.0284  -16.285    0.000     0.972     0.614
      excellent    vs good         |   -0.0102   -5.739    0.000     0.990     0.839
      ------------------------------------------------------------------------------
      
      Variable: height (sd=9.660)
      ------------------------------------------------------------------------------
                                   |         b        z    P>|z|       e^b   e^bStdX
      -----------------------------+------------------------------------------------
      poor         vs fair         |    0.0153    2.863    0.004     1.015     1.160
      poor         vs excellent    |   -0.0314   -5.829    0.000     0.969     0.738
      fair         vs poor         |   -0.0153   -2.863    0.004     0.985     0.862
      fair         vs average      |   -0.0110   -2.933    0.003     0.989     0.899
      fair         vs good         |   -0.0274   -6.914    0.000     0.973     0.768
      fair         vs excellent    |   -0.0468  -11.276    0.000     0.954     0.636
      average      vs fair         |    0.0110    2.933    0.003     1.011     1.112
      average      vs good         |   -0.0164   -4.886    0.000     0.984     0.854
      average      vs excellent    |   -0.0358  -10.138    0.000     0.965     0.708
      good         vs fair         |    0.0274    6.914    0.000     1.028     1.302
      good         vs average      |    0.0164    4.886    0.000     1.016     1.171
      good         vs excellent    |   -0.0194   -5.443    0.000     0.981     0.829
      excellent    vs poor         |    0.0314    5.829    0.000     1.032     1.355
      excellent    vs fair         |    0.0468   11.276    0.000     1.048     1.571
      excellent    vs average      |    0.0358   10.138    0.000     1.036     1.413
      excellent    vs good         |    0.0194    5.443    0.000     1.020     1.206
      ------------------------------------------------------------------------------
             b = raw coefficient
             z = z-score for test of b=0
         P>|z| = p-value for z-test
           e^b = exp(b) = factor change in odds for unit increase in X
       e^bStdX = exp(b*SD of X) = change in odds for SD increase in X

      Comment


      • #4
        I don't think listcoef will give you what you want. Is this closer to what you have in mind?

        Code:
        . margins, dydx(*) pwcompare(pveffects)
        
        Pairwise comparisons of average marginal effects
        Model VCE    : OIM
        
        dy/dx w.r.t. : weight age height
        1._predict   : Pr(health==poor), predict(pr outcome(1))
        2._predict   : Pr(health==fair), predict(pr outcome(2))
        3._predict   : Pr(health==average), predict(pr outcome(3))
        4._predict   : Pr(health==good), predict(pr outcome(4))
        5._predict   : Pr(health==excellent), predict(pr outcome(5))
        
        -----------------------------------------------------
                     |   Contrast Delta-method    Unadjusted
                     |      dy/dx   Std. Err.      z    P>|z|
        -------------+---------------------------------------
        weight       |
            _predict |
             2 vs 1  |   .0010101   .0003346     3.02   0.003
             3 vs 1  |   .0003256   .0004018     0.81   0.418
             4 vs 1  |  -.0008809   .0003881    -2.27   0.023
             5 vs 1  |  -.0026114   .0003824    -6.83   0.000
             3 vs 2  |  -.0006845   .0004652    -1.47   0.141
             4 vs 2  |  -.0018911   .0004479    -4.22   0.000
             5 vs 2  |  -.0036215   .0004415    -8.20   0.000
             4 vs 3  |  -.0012066   .0005309    -2.27   0.023
             5 vs 3  |   -.002937   .0005301    -5.54   0.000
             5 vs 4  |  -.0017305   .0005337    -3.24   0.001
        -------------+---------------------------------------
        age          |
            _predict |
             2 vs 1  |   .0009758   .0003539     2.76   0.006
             3 vs 1  |  -.0026218    .000363    -7.22   0.000
             4 vs 1  |  -.0064774   .0003308   -19.58   0.000
             5 vs 1  |  -.0081566   .0003155   -25.86   0.000
             3 vs 2  |  -.0035975   .0003848    -9.35   0.000
             4 vs 2  |  -.0074532   .0003501   -21.29   0.000
             5 vs 2  |  -.0091324   .0003349   -27.27   0.000
             4 vs 3  |  -.0038556   .0003828   -10.07   0.000
             5 vs 3  |  -.0055349   .0003792   -14.60   0.000
             5 vs 4  |  -.0016793   .0003915    -4.29   0.000
        -------------+---------------------------------------
        height       |
            _predict |
             2 vs 1  |  -.0028687   .0005525    -5.19   0.000
             3 vs 1  |  -.0027395   .0006546    -4.19   0.000
             4 vs 1  |    .001218   .0006256     1.95   0.052
             5 vs 1  |   .0053611   .0006063     8.84   0.000
             3 vs 2  |   .0001293   .0007728     0.17   0.867
             4 vs 2  |   .0040868    .000734     5.57   0.000
             5 vs 2  |   .0082298   .0007107    11.58   0.000
             4 vs 3  |   .0039575   .0008635     4.58   0.000
             5 vs 3  |   .0081006   .0008465     9.57   0.000
             5 vs 4  |    .004143   .0008447     4.90   0.000
        -----------------------------------------------------
        .
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Yes, this is what I am after. Thank you!
          I am just wondering about the changes in some of the levels of significance. For example for the height variable:
          Code:
          average      vs fair         |    0.0110    2.933    0.003     1.011     1.112
          (obatained from the listcoef after mlogit) seems to be of significance while
          Code:
          3 vs 2  |   .0001293   .0007728     0.17   0.867
          (obtained after margins, dydx(*) pwcompare(pveffects)) seems not be significant. Is this possible?

          Also, I am wandering what the direction of interpretation is. Intuitivley I would assume something along the lines of: A one unit increase in terms weight increases the propability of beeing in fair instead of poor health by 0.1 %. It seems a bit strange to me that Stata displays 2 vs. 1 instead of 1 vs. 2.

          Comment


          • #6
            Thanks again for all your help.
            Just to reiterate: I'm interested in obtaining something which would allow me to make a statement along the lines of: A one unit increase in terms of weight increases the propability of being in fair instead of poor health by 0.1 %, for each variable for each cross categorical comparison (if significant). I think I may have unnecessarily complicated the question on how to obtain this.

            Comment


            • #7
              For significance of original effects vs marginal effects you may want to see

              http://www.statalist.org/forums/foru...s-significance

              For interpreting marginal effects in general, I suggest

              http://www3.nd.edu/~rwilliam/stats3/Margins01.pdf

              http://www3.nd.edu/~rwilliam/stats3/Margins02.pdf

              http://www3.nd.edu/~rwilliam/stats3/Margins03.pdf

              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              Stata Version: 17.0 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment


              • #8
                hello
                I would like to estimate a multinomial logit model, but stata put "Mata object '__000003' not found r(111)"
                What that's mean?
                Thank for helping me

                Comment


                • #9
                  Hello again, I reviewed the information Richard provided on interpreting marginal effects and also consulted "Regression Models for Categorical Dependent Variables Using Stata" (Long&Freese, 2014).
                  However, I'm still not sure how to interpret the results obtained via the pwcompare command.
                  My goal was to obtain information similar to the one gained from using relative risk ratios, that is how variables affect the choice of one outcome compared with another outcome.
                  Does the pwcompare margins command provide that info? And if it does, does it make sense to use marginal effects in this context?
                  Long & Freese suggest using the mchange command to obtain information on the marginal effects and then using relative risk ratios to show the dynamics among the outcomes.

                  Comment

                  Working...
                  X