Announcement

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

  • Ologit postestimation : mchange instead of prtab

    Hello everyone,

    I try to get predicted values of the independent variables according to the predicted probability of outcomes of the dependent variable after ologit. With Spost9, i used prtab but with Spost13 and mchange I can't get it. I don't know how to do it. I've tried many commands but I don't get this kind of stats.
    IMy model is ologit y x1 x2 x3


    Click image for larger version

Name:	prtabX1.png
Views:	1
Size:	6.8 KB
ID:	1763602


    Thanks for help !

  • #2
    You could use mtable from SPost 13 or margins to get the predicted probabilities.

    Code:
    net install spost13_ado, from(https://jslsoc.sitehost.iu.edu/stata)

    Code:
    webuse fullauto, clear
    replace mpg= ceil(mpg/5)
    ologit rep77 i.foreign length i.mpg
    mtable, at(foreign = (0/1) mpg = (4/9))
    margins, at(foreign = (0/1) mpg = (4/9))
    Res.:

    Code:
    . ologit rep77 i.foreign length i.mpg
    
    Iteration 0:  Log likelihood = -89.895098  
    Iteration 1:  Log likelihood = -75.214089  
    Iteration 2:  Log likelihood = -73.982729  
    Iteration 3:  Log likelihood = -73.901066  
    Iteration 4:  Log likelihood = -73.900793  
    Iteration 5:  Log likelihood = -73.900793  
    
    Ordered logistic regression                             Number of obs =     66
                                                            LR chi2(8)    =  31.99
                                                            Prob > chi2   = 0.0001
    Log likelihood = -73.900793                             Pseudo R2     = 0.1779
    
    ------------------------------------------------------------------------------
           rep77 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         foreign |
        Foreign  |   3.111388    .838715     3.71   0.000     1.467537     4.75524
          length |   .0879074   .0256217     3.43   0.001     .0376899     .138125
                 |
             mpg |
              4  |   .7506705   .8184084     0.92   0.359    -.8533805    2.354721
              5  |   1.233249   1.077106     1.14   0.252    -.8778397    3.344338
              6  |   4.643723   1.769066     2.62   0.009     1.176417    8.111029
              7  |   6.337993   1.852357     3.42   0.001     2.707439    9.968546
              8  |   3.582475   2.154815     1.66   0.096    -.6408841    7.805834
              9  |   4.457306   2.370814     1.88   0.060    -.1894042    9.104016
    -------------+----------------------------------------------------------------
           /cut1 |   15.33958   5.475728                      4.607346     26.0718
           /cut2 |   17.32266   5.529102                      6.485816     28.1595
           /cut3 |   19.73083   5.662284                      8.632955     30.8287
           /cut4 |   22.65787   5.815867                      11.25898    34.05676
    ------------------------------------------------------------------------------
    
    .
    . mtable, at(foreign = (0/1) mpg = (4/9))
    
    Expression: Pr(rep77), predict(outcome())
    
               |  foreign       mpg      Poor      Fair   Average      Good  Excellent
     ----------+----------------------------------------------------------------------
             1 |        0         4     0.231     0.256     0.320     0.172      0.021
             2 |        0         5     0.179     0.242     0.330     0.217      0.032
             3 |        0         6     0.012     0.057     0.221     0.398      0.312
             4 |        0         7     0.002     0.014     0.099     0.337      0.548
             5 |        0         8     0.032     0.112     0.285     0.388      0.183
             6 |        0         9     0.015     0.065     0.234     0.400      0.287
             7 |        1         4     0.025     0.095     0.271     0.395      0.214
             8 |        1         5     0.016     0.070     0.242     0.400      0.272
             9 |        1         6     0.001     0.004     0.035     0.228      0.733
            10 |        1         7     0.000     0.001     0.008     0.093      0.898
            11 |        1         8     0.002     0.010     0.078     0.314      0.596
            12 |        1         9     0.001     0.004     0.041     0.245      0.710
    
    Specified values where .n indicates no values specified with at()
    
               |  No at()
     ----------+---------
       Current |       .n
    
    .
    . margins, at(foreign = (0/1) mpg = (4/9))
    
    Predictive margins                                          Number of obs = 66
    Model VCE: OIM
    
    1._predict: Pr(rep77==1), predict(pr outcome(1))
    2._predict: Pr(rep77==2), predict(pr outcome(2))
    3._predict: Pr(rep77==3), predict(pr outcome(3))
    4._predict: Pr(rep77==4), predict(pr outcome(4))
    5._predict: Pr(rep77==5), predict(pr outcome(5))
    
    1._at:  foreign = 0
            mpg     = 4
    2._at:  foreign = 0
            mpg     = 5
    3._at:  foreign = 0
            mpg     = 6
    4._at:  foreign = 0
            mpg     = 7
    5._at:  foreign = 0
            mpg     = 8
    6._at:  foreign = 0
            mpg     = 9
    7._at:  foreign = 1
            mpg     = 4
    8._at:  foreign = 1
            mpg     = 5
    9._at:  foreign = 1
            mpg     = 6
    10._at: foreign = 1
            mpg     = 7
    11._at: foreign = 1
            mpg     = 8
    12._at: foreign = 1
            mpg     = 9
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    _predict#_at |
           1  1  |   .2306169   .1036152     2.23   0.026     .0275348     .433699
           1  2  |   .1787519   .0806957     2.22   0.027     .0205912    .3369127
           1  3  |   .0123046   .0126287     0.97   0.330    -.0124471    .0370564
           1  4  |   .0023722   .0032044     0.74   0.459    -.0039082    .0086527
           1  5  |   .0323638   .0502105     0.64   0.519     -.066047    .1307745
           1  6  |   .0146602   .0276853     0.53   0.596    -.0396019    .0689223
           1  7  |   .0252867   .0244198     1.04   0.300    -.0225752    .0731486
           1  8  |   .0162824   .0123558     1.32   0.188    -.0079345    .0404994
           1  9  |   .0005801   .0007122     0.81   0.415    -.0008158     .001976
           1 10  |   .0001068   .0001554     0.69   0.492    -.0001977    .0004114
           1 11  |   .0016677   .0032455     0.51   0.607    -.0046935    .0080288
           1 12  |   .0006986   .0013831     0.51   0.613    -.0020121    .0034094
           2  1  |   .2564493     .07593     3.38   0.001     .1076292    .4052694
           2  2  |   .2420307   .0710461     3.41   0.001     .1027829    .3812784
           2  3  |   .0566954    .040561     1.40   0.162    -.0228027    .1361936
           2  4  |   .0137556   .0162039     0.85   0.396    -.0180035    .0455147
           2  5  |   .1116688   .1041441     1.07   0.284    -.0924499    .3157874
           2  6  |   .0647605    .089256     0.73   0.468     -.110178     .239699
           2  7  |   .0952322   .0512467     1.86   0.063    -.0052095     .195674
           2  8  |     .06999   .0311649     2.25   0.025     .0089079     .131072
           2  9  |   .0035617   .0036951     0.96   0.335    -.0036806     .010804
           2 10  |   .0006668   .0008792     0.76   0.448    -.0010564      .00239
           2 11  |   .0098807   .0172384     0.57   0.567    -.0239059    .0436672
           2 12  |   .0042718   .0079038     0.54   0.589    -.0112193     .019763
           3  1  |   .3198576    .063735     5.02   0.000     .1949393    .4447759
           3  2  |   .3299538   .0654251     5.04   0.000      .201723    .4581846
           3  3  |   .2210075   .0776252     2.85   0.004     .0688649    .3731501
           3  4  |   .0990966   .0774549     1.28   0.201    -.0527123    .2509055
           3  5  |   .2847533   .1002534     2.84   0.005     .0882602    .4812464
           3  6  |   .2339751    .137689     1.70   0.089    -.0358903    .5038406
           3  7  |   .2705641   .0571616     4.73   0.000     .1585293    .3825988
           3  8  |   .2415057   .0550758     4.38   0.000     .1335592    .3494523
           3  9  |   .0349133   .0279893     1.25   0.212    -.0199447    .0897713
           3 10  |   .0075151   .0088848     0.85   0.398    -.0098988    .0249289
           3 11  |   .0784785   .0988736     0.79   0.427    -.1153102    .2722673
           3 12  |   .0406964   .0612397     0.66   0.506    -.0793313     .160724
           4  1  |     .17231   .0423855     4.07   0.000     .0892359    .2553842
           4  2  |   .2171843   .0625528     3.47   0.001      .094583    .3397856
           4  3  |   .3982522   .1099092     3.62   0.000     .1828342    .6136702
           4  4  |    .337004   .1079346     3.12   0.002     .1254561    .5485519
           4  5  |   .3883496   .0920562     4.22   0.000     .2079227    .5687764
           4  6  |   .3995606    .104885     3.81   0.000     .1939898    .6051314
           4  7  |   .3952213   .0935119     4.23   0.000     .2119414    .5785012
           4  8  |   .3997572   .1025256     3.90   0.000     .1988106    .6007037
           4  9  |   .2283967   .1156364     1.98   0.048     .0017536    .4550399
           4 10  |   .0933377   .0734417     1.27   0.204    -.0506054    .2372808
           4 11  |   .3138245   .1640583     1.91   0.056    -.0077239    .6353729
           4 12  |   .2445977   .1723933     1.42   0.156     -.093287    .5824825
           5  1  |   .0207662   .0146011     1.42   0.155    -.0078515     .049384
           5  2  |   .0320793   .0277486     1.16   0.248    -.0223069    .0864656
           5  3  |   .3117403   .1780666     1.75   0.080    -.0372639    .6607444
           5  4  |   .5477716   .1698269     3.23   0.001      .214917    .8806261
           5  5  |   .1828646   .2061638     0.89   0.375    -.2212091    .5869383
           5  6  |   .2870435   .2713608     1.06   0.290    -.2448139    .8189009
           5  7  |   .2136958   .1121642     1.91   0.057     -.006142    .4335335
           5  8  |   .2724647   .1288463     2.11   0.034     .0199305    .5249989
           5  9  |   .7325481   .1399473     5.23   0.000     .4582564     1.00684
           5 10  |   .8983736   .0816978    11.00   0.000     .7382489    1.058498
           5 11  |   .5961486   .2683376     2.22   0.026     .0702166    1.122081
           5 12  |   .7097355   .2360461     3.01   0.003     .2470936    1.172377
    ------------------------------------------------------------------------------
    
    .

    Comment


    • #3
      Thank you so much for the solution that gives me exactly the same results as the prtab command in the old version

      Code:
      . mtable, at(x1=(0 1)) atmeans
      
      Expression: Pr(y), predict(outcome())
      
                 |       x1         0         1         2
       ----------+---------------------------------------
               1 |        0     0.370     0.506     0.123
               2 |        1     0.700     0.266     0.034
      
      Specified values of covariates
      
                 |       x2        x3
       ----------+-------------------
         Current |     5.42     .0819
      Last edited by Gabrielle Doe; 12 Sep 2024, 15:07.

      Comment

      Working...
      X