Announcement

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

  • Plot of melogit model

    Hello all, I am running a single level logit model cluster at kindergarten level. Below is the model output.

    Code:
     logit gedtimehi c.grade##c.grade ib6.RACE ib6.RACE#c.grade ib6.RACE#c.grade#c.grade, cluster(kinde
    > rgarten)
    
    Iteration 0:   log pseudolikelihood =  -6318.348  
    Iteration 1:   log pseudolikelihood =  -6219.052  
    Iteration 2:   log pseudolikelihood = -6218.0061  
    Iteration 3:   log pseudolikelihood = -6218.0061  
    
    Logistic regression                               Number of obs   =      11088
                                                      Wald chi2(11)   =      76.81
                                                      Prob > chi2     =     0.0000
    Log pseudolikelihood = -6218.0061                 Pseudo R2       =     0.0159
    
                                            (Std. Err. adjusted for 41 clusters in kindergarten)
    --------------------------------------------------------------------------------------------
                               |               Robust
                     gedtimehi |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------------+----------------------------------------------------------------
                      gradelvl |   .1603621   .0765065     2.10   0.036     .0104121     .310312
                               |
         c.gradelvl#c.gradelvl |  -.0272459   .0092321    -2.95   0.003    -.0453405   -.0091512
                               |
                          RACE |
             African American  |  -.4808764   .1205788    -3.99   0.000    -.7172065   -.2445462
                        Asian  |  -.2261637   .1346057    -1.68   0.093    -.4899861    .0376587
                     Hispanic  |   .0902261   .1429301     0.63   0.528    -.1899117     .370364
                               |
               RACE#c.gradelvl |
             African American  |  -.0361761   .0762349    -0.47   0.635    -.1855937    .1132415
                        Asian  |   .1960031   .1015358     1.93   0.054    -.0030035    .3950097
                     Hispanic  |  -.0600909   .0959935    -0.63   0.531    -.2482346    .1280528
                               |
    RACE#c.gradelvl#c.gradelvl |
             African American  |   .0081719   .0094204     0.87   0.386    -.0102918    .0266357
                        Asian  |    -.02058   .0134071    -1.54   0.125    -.0468575    .0056974
                     Hispanic  |   .0001009    .012092     0.01   0.993    -.0235989    .0238007
                               |
                         _cons |   1.156505    .157408     7.35   0.000     .8479907    1.465019
    --------------------------------------------------------------------------------------------
    Based from the model results, it seems none of the interaction terms is significant. So, I suppose the plot by racial groups generated based on the model should have parallel lines.

    Below is the plot I generated using margins and marginsplot.

    Code:
    . margins RACE, at(grade=(0(1)9))
    
    Adjusted predictions                              Number of obs   =      11088
    Model VCE    : Robust
    
    Expression   : Pr(gedtimehi), predict()
    
    1._at        : gradelvl        =           0
    
    2._at        : gradelvl        =           1
    
    3._at        : gradelvl        =           2
    
    4._at        : gradelvl        =           3
    
    5._at        : gradelvl        =           4
    
    6._at        : gradelvl        =           5
    
    7._at        : gradelvl        =           6
    
    8._at        : gradelvl        =           7
    
    9._at        : gradelvl        =           8
    
    10._at       : gradelvl        =           9
    
    --------------------------------------------------------------------------------------
                         |            Delta-method
                         |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------------+----------------------------------------------------------------
                _at#RACE |
     1#African American  |   .6627623   .0450391    14.72   0.000     .5744873    .7510373
                1#Asian  |   .7171445   .0382939    18.73   0.000     .6420897    .7921992
             1#Hispanic  |   .7767334   .0330955    23.47   0.000     .7118675    .8415994
                1#White  |    .760697   .0286541    26.55   0.000      .704536     .816858
     2#African American  |   .6858397    .035863    19.12   0.000     .6155494    .7561299
                2#Asian  |   .7753691   .0274055    28.29   0.000     .7216552    .8290829
             2#Hispanic  |   .7891579   .0260394    30.31   0.000     .7381217    .8401942
                2#White  |    .784083   .0215603    36.37   0.000     .7418256    .8263405
     3#African American  |   .7000854   .0304276    23.01   0.000     .6404483    .7597225
                3#Asian  |   .8102704   .0224043    36.17   0.000     .7663588     .854182
             3#Hispanic  |    .792275   .0227092    34.89   0.000     .7477658    .8367842
                3#White  |   .7970965   .0197392    40.38   0.000     .7584084    .8357846
     4#African American  |   .7061007     .02703    26.12   0.000     .6531229    .7590786
                4#Asian  |   .8276415   .0201961    40.98   0.000      .788058     .867225
             4#Hispanic  |   .7863797     .02188    35.94   0.000     .7434958    .8292637
                4#White  |   .8009716   .0201024    39.84   0.000     .7615715    .8403717
     5#African American  |   .7041605    .024499    28.74   0.000     .6561433    .7521777
                5#Asian  |   .8306987   .0193026    43.04   0.000     .7928664    .8685311
             5#Hispanic  |    .770917   .0227636    33.87   0.000     .7263012    .8155328
                5#White  |   .7960876   .0207723    38.32   0.000     .7553746    .8368007
     6#African American  |   .6941747   .0228595    30.37   0.000     .6493708    .7389786
                6#Asian  |   .8200254   .0197917    41.43   0.000     .7812345    .8588163
             6#Hispanic  |   .7444948    .025372    29.34   0.000     .6947667    .7942229
                6#White  |   .7819674   .0212253    36.84   0.000     .7403665    .8235683
     7#African American  |   .6757004   .0240232    28.13   0.000     .6286159     .722785
                7#Asian  |    .793606   .0234798    33.80   0.000     .7475864    .8396255
             7#Hispanic  |   .7049829   .0306699    22.99   0.000     .6448709    .7650948
                7#White  |   .7572802   .0221361    34.21   0.000     .7138943    .8006661
     8#African American  |   .6480108   .0311325    20.81   0.000     .5869922    .7090294
                8#Asian  |   .7467642   .0339852    21.97   0.000     .6801545     .813374
             8#Hispanic  |   .6498835   .0401807    16.17   0.000     .5711308    .7286362
                8#White  |   .7199052   .0260306    27.66   0.000     .6688862    .7709242
     9#African American  |   .6102549   .0455753    13.39   0.000     .5209289    .6995809
                9#Asian  |   .6726963   .0546883    12.30   0.000     .5655092    .7798833
             9#Hispanic  |   .5772817   .0547091    10.55   0.000     .4700537    .6845096
                9#White  |    .667226   .0366886    18.19   0.000     .5953177    .7391344
    10#African American  |   .5617611   .0666693     8.43   0.000     .4310916    .6924306
               10#Asian  |   .5655531   .0850815     6.65   0.000     .3987964    .7323098
            10#Hispanic  |   .4876104   .0726647     6.71   0.000     .3451903    .6300306
               10#White  |    .596968   .0557985    10.70   0.000      .487605    .7063311
    --------------------------------------------------------------------------------------
    
    . marginsplot, noci recast(line)
    Click image for larger version

Name:	test.png
Views:	1
Size:	90.9 KB
ID:	1395795


    Is the plot correct based on the model result? Shouldn't the lines be parallel instead of crossing over? Is it always the case that if no interaction effects is significant, the lines should not cross each other?

  • #2
    An interaction term is not necessarily negligible even if a test fails to reject the null hypothesis that its components are jointly equal to zero.

    Also, the marginal proportions are nonlinear; if you want to see how far the lines deviate from parallel, then plot the linear predictions
    Code:
    margins RACE, at(grade=(0(1)9)) predict(xb)

    Comment


    • #3
      Hi Joseph, thanks for your reply. I tried the code you provided below

      Code:
      . margins RACE, at(grade=(0(1)9)) predict(xb)
      
      Adjusted predictions                              Number of obs   =      11088
      Model VCE    : Robust
      
      Expression   : Linear prediction (log odds), predict(xb)
      
      1._at        : gradelvl        =           0
      
      2._at        : gradelvl        =           1
      
      3._at        : gradelvl        =           2
      
      4._at        : gradelvl        =           3
      
      5._at        : gradelvl        =           4
      
      6._at        : gradelvl        =           5
      
      7._at        : gradelvl        =           6
      
      8._at        : gradelvl        =           7
      
      9._at        : gradelvl        =           8
      
      10._at       : gradelvl        =           9
      
      --------------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
      ---------------------+----------------------------------------------------------------
                  _at#RACE |
       1#African American  |   .6756283   .2015097     3.35   0.001     .2806767     1.07058
                  1#Asian  |    .930341   .1887812     4.93   0.000     .5603366    1.300345
               1#Hispanic  |   1.246731   .1908416     6.53   0.000     .8726881    1.620773
                  1#White  |   1.156505    .157408     7.35   0.000     .8479907    1.465019
       2#African American  |   .7807404   .1664459     4.69   0.000     .4545124    1.106968
                  2#Asian  |    1.23888   .1573476     7.87   0.000     .9304847    1.547276
               2#Hispanic  |   1.319857   .1564982     8.43   0.000     1.013126    1.626588
                  2#White  |   1.289621   .1273522    10.13   0.000     1.040015    1.539227
       3#African American  |   .8477045   .1449171     5.85   0.000     .5636722    1.131737
                  3#Asian  |   1.451768   .1457357     9.96   0.000     1.166131    1.737405
               3#Hispanic  |   1.338693   .1379867     9.70   0.000     1.068244    1.609142
                  3#White  |   1.368245   .1220476    11.21   0.000     1.129036    1.607454
       4#African American  |   .8765207    .130251     6.73   0.000     .6212335    1.131808
                  4#Asian  |   1.569004   .1415766    11.08   0.000     1.291518    1.846489
               4#Hispanic  |    1.30324   .1302483    10.01   0.000     1.047958    1.558522
                  4#White  |   1.392378   .1261005    11.04   0.000     1.145226     1.63953
       5#African American  |   .8671891   .1176037     7.37   0.000     .6366901    1.097688
                  5#Asian  |   1.590587   .1372496    11.59   0.000     1.321583    1.859592
               5#Hispanic  |   1.213496   .1288962     9.41   0.000     .9608646    1.466128
                  5#White  |   1.362019   .1279619    10.64   0.000     1.111218     1.61282
       6#African American  |   .8197095   .1076776     7.61   0.000     .6086654    1.030754
                  6#Asian  |    1.51652   .1341046    11.31   0.000     1.253679     1.77936
               6#Hispanic  |   1.069463   .1333806     8.02   0.000     .8080421    1.330884
                  6#White  |   1.277168   .1244929    10.26   0.000     1.033167     1.52117
       7#African American  |   .7340821     .10963     6.70   0.000     .5192112     .948953
                  7#Asian  |     1.3468   .1433483     9.40   0.000     1.065843    1.627757
               7#Hispanic  |   .8711401   .1474643     5.91   0.000     .5821153    1.160165
                  7#White  |   1.137826   .1204311     9.45   0.000     .9017851    1.373866
       8#African American  |   .6103068   .1364905     4.47   0.000     .3427903    .8778233
                  8#Asian  |   1.081429   .1797136     6.02   0.000     .7291964    1.433661
               8#Hispanic  |   .6185272   .1765913     3.50   0.000     .2724147    .9646396
                  8#White  |   .9439914   .1290932     7.31   0.000     .6909735    1.197009
       9#African American  |   .4483837   .1916187     2.34   0.019      .072818    .8239493
                  9#Asian  |   .7204054   .2483844     2.90   0.004     .2335809     1.20723
               9#Hispanic  |   .3116243   .2241925     1.39   0.165    -.1277849    .7510335
                  9#White  |   .6956654   .1652376     4.21   0.000     .3718056    1.019525
      10#African American  |   .2483126   .2708093     0.92   0.359    -.2824639    .7790891
                 10#Asian  |   .2637304   .3462782     0.76   0.446    -.4149624    .9424232
              10#Hispanic  |  -.0495684   .2908372    -0.17   0.865    -.6195988    .5204621
                 10#White  |   .3928477   .2319167     1.69   0.090    -.0617006     .847396
      --------------------------------------------------------------------------------------
      But the marginsplot I got is quite similar to what I got without using predict(xb). Are they supposed to be the same or different?

      Click image for larger version

Name:	test.png
Views:	1
Size:	99.6 KB
ID:	1395934

      Comment


      • #4
        Your model has a quadratic term c.gradelvl#c.gradelvl that your plotting over. That's why the plots are curved. The degree to which the curves share the same shape and location is what you're looking for in terms of assessing the interaction of grade and race.

        Comment


        • #5
          Thanks Joseph, so can you tell me what is the difference between not adding predict(xb) versus adding it? I suppose predict(xb) is the linear prediction from the fitted model but what are the predictions without adding predict(xb)? Are there supposed to be a preference over which one I should plot?

          Comment


          • #6
            Originally posted by Man Yang View Post
            I suppose predict(xb) is the linear prediction from the fitted model but what are the predictions without adding predict(xb)?
            You get the default prediction for the estimation command. In your case the proportions, Look at the y-axis title of the -marginsplot-. It tells you what it is. You can also find out from -help logit_postestimation- what the default is.


            Originally posted by Man Yang View Post
            Are there supposed to be a preference over which one I should plot?
            The choice depends upon the purpose. If you're trying to assess an interaction, then use the linear predictions. If you're trying to communicate the results to an audience that has trouble with log odds, then proportions might be helpful.

            Comment


            • #7
              Thanks a lot for your answer!

              Comment

              Working...
              X