Chapter 16 - Multinomial and Ordered Response Models

Examples

------------------------------------------------------------------------------------------
      name:  SN
       log:  \iiexample16.smcl
  log type:  smcl
 closed on:  11 May 2020, 08:09:51
. **********************************************
. * Solomon Negash - Examples
. * Wooldridge (2010). Economic Analysis of Cross-Section and Panel Data. 2nd ed.  
. * STATA Program, version 16.1. 

. * Chapter 16  - Multinomial and Ordered Response Models
. ******************** SETUP *********************

. // Example 16.1 (School and Employment Decisions for Young Men)
.  bcuse keane, clear nodesc

. keep if year==87
(10,985 observations deleted)

. eststo MLogit: mlogit status educ exper expersq black, baseoutcome(1)

Iteration 0:   log likelihood = -1199.7182  
Iteration 1:   log likelihood = -960.26272  
Iteration 2:   log likelihood =  -908.7673  
Iteration 3:   log likelihood = -907.85992  
Iteration 4:   log likelihood = -907.85723  
Iteration 5:   log likelihood = -907.85723  

Multinomial logistic regression                 Number of obs     =      1,717
                                                LR chi2(8)        =     583.72
                                                Prob > chi2       =     0.0000
Log likelihood = -907.85723                     Pseudo R2         =     0.2433

------------------------------------------------------------------------------
      status |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
1            |  (base outcome)
-------------+----------------------------------------------------------------
2            |
        educ |  -.6736313   .0698999    -9.64   0.000    -.8106325     -.53663
       exper |  -.1062149    .173282    -0.61   0.540    -.4458414    .2334116
     expersq |  -.0125152   .0252291    -0.50   0.620    -.0619633     .036933
       black |   .8130166   .3027231     2.69   0.007     .2196902    1.406343
       _cons |   10.27787   1.133336     9.07   0.000     8.056578    12.49917
-------------+----------------------------------------------------------------
3            |
        educ |  -.3146573   .0651096    -4.83   0.000    -.4422699   -.1870448
       exper |   .8487367   .1569856     5.41   0.000     .5410507    1.156423
     expersq |  -.0773003   .0229217    -3.37   0.001    -.1222261   -.0323746
       black |   .3113612   .2815339     1.11   0.269     -.240435    .8631574
       _cons |   5.543798   1.086409     5.10   0.000     3.414475    7.673121
------------------------------------------------------------------------------





. esttab MLogit, se stats(N ll r2_p) b(%8.3f) nostar not unstack compress

----------------------------------------
                 (1)                    
              status                    
                   1         2         3
----------------------------------------
educ           0.000    -0.674    -0.315
                 (.)   (0.070)   (0.065)

exper          0.000    -0.106     0.849
                 (.)   (0.173)   (0.157)

expersq        0.000    -0.013    -0.077
                 (.)   (0.025)   (0.023)

black          0.000     0.813     0.311
                 (.)   (0.303)   (0.282)

_cons          0.000    10.278     5.544
                 (.)   (1.133)   (1.086)
----------------------------------------
N           1717.000                    
ll          -907.857                    
r2_p           0.243                    
----------------------------------------
Standard errors in parentheses

. eststo clear 

. * Percentages correctly predicted

. predict pr1 pr2 pr3, pr

. g prst = .
(1,738 missing values generated)

. egen prmax = rmax(pr1 pr2 pr3)  

. forval i= 1/3 {
  2.         replace prst = `i' if pr`i'==prmax
  3.                 }
(15 real changes made)
(197 real changes made)
(1,526 real changes made)

. g prdf = (status == prst)

. tab prdf if exper!=. & black !=. & status !=.

       prdf |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        351       20.44       20.44
          1 |      1,366       79.56      100.00
------------+-----------------------------------
      Total |      1,717      100.00

. di "Percent correctly predicted = "  1366 /1717
Percent correctly predicted = .79557368

. test [2]: exper expersq

 ( 1)  [2]exper = 0
 ( 2)  [2]expersq = 0

           chi2(  2) =    6.12
         Prob > chi2 =    0.0468

. test [3]: exper expersq

 ( 1)  [3]exper = 0
 ( 2)  [3]expersq = 0

           chi2(  2) =   39.63
         Prob > chi2 =    0.0000






.  // Example 16.2 (Asset Allocation in Pension Plans)

. bcuse pension, clear nodesc

. reg pctstck choice age educ female black married finc* wealth89 prftshr 

      Source |       SS           df       MS      Number of obs   =       194
-------------+----------------------------------   F(14, 179)      =      1.42
       Model |  30402.0516        14  2171.57511   Prob > F        =    0.1486
    Residual |  274134.031       179  1531.47503   R-squared       =    0.0998
-------------+----------------------------------   Adj R-squared   =    0.0294
       Total |  304536.082       193  1577.90716   Root MSE        =    39.134

------------------------------------------------------------------------------
     pctstck |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      choice |   12.04773   6.298171     1.91   0.057    -.3804884    24.47594
         age |  -1.625967   .7748246    -2.10   0.037    -3.154932   -.0970012
        educ |   .7538685   1.207392     0.62   0.533    -1.628684    3.136422
      female |   1.302856   7.163775     0.18   0.856    -12.83346    15.43917
       black |   3.967391   9.782799     0.41   0.686    -15.33706    23.27184
     married |   3.303436   7.997618     0.41   0.680    -12.47831    19.08518
      finc25 |  -18.18567   14.12026    -1.29   0.199    -46.04925    9.677907
      finc35 |  -3.925374   14.48565    -0.27   0.787    -32.50999    24.65924
      finc50 |  -8.128784   14.34191    -0.57   0.572    -36.42976    20.17219
      finc75 |  -17.57921   16.07766    -1.09   0.276    -49.30534    14.14693
     finc100 |   -6.74559   15.79116    -0.43   0.670    -37.90637    24.41519
     finc101 |  -28.34407    17.9049    -1.58   0.115    -63.67591    6.987775
    wealth89 |  -.0026918   .0124603    -0.22   0.829    -.0272797    .0218961
     prftshr |   15.80791   7.332677     2.16   0.032     1.338299    30.27752
       _cons |   134.1161   55.70525     2.41   0.017      24.1926    244.0395
------------------------------------------------------------------------------

. oprobit pctstck choice age educ female black married finc* wealth89 prftshr

Iteration 0:   log likelihood = -212.37031  
Iteration 1:   log likelihood =  -202.0094  
Iteration 2:   log likelihood =  -201.9865  
Iteration 3:   log likelihood =  -201.9865  

Ordered probit regression                       Number of obs     =        194
                                                LR chi2(14)       =      20.77
                                                Prob > chi2       =     0.1077
Log likelihood =  -201.9865                     Pseudo R2         =     0.0489

------------------------------------------------------------------------------
     pctstck |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      choice |    .371171   .1841121     2.02   0.044      .010318    .7320241
         age |  -.0500516   .0226063    -2.21   0.027    -.0943591    -.005744
        educ |   .0261382   .0352561     0.74   0.458    -.0429626    .0952389
      female |   .0455642    .206004     0.22   0.825    -.3581963    .4493246
       black |   .0933923   .2820403     0.33   0.741    -.4593965    .6461811
     married |   .0935981   .2332114     0.40   0.688    -.3634878     .550684
      finc25 |  -.5784299    .423162    -1.37   0.172    -1.407812    .2509524
      finc35 |  -.1346721   .4305242    -0.31   0.754    -.9784841    .7091399
      finc50 |  -.2620401   .4265936    -0.61   0.539    -1.098148    .5740681
      finc75 |  -.5662312   .4780035    -1.18   0.236    -1.503101    .3706385
     finc100 |  -.2278963   .4685942    -0.49   0.627    -1.146324    .6905316
     finc101 |  -.8641109   .5291111    -1.63   0.102     -1.90115    .1729279
    wealth89 |  -.0000956   .0003737    -0.26   0.798    -.0008279    .0006368
     prftshr |   .4817182   .2161233     2.23   0.026     .0581243     .905312
-------------+----------------------------------------------------------------
       /cut1 |  -3.087373   1.623765                     -6.269894    .0951479
       /cut2 |  -2.053553   1.618611                     -5.225972    1.118865
------------------------------------------------------------------------------


. gen pcr=.
(194 missing values generated)

. predict pr1, outcome(0)
(option pr assumed; predicted probability)

. predict pr2, outcome(50)
(option pr assumed; predicted probability)

. predict pr3, outcome(100)
(option pr assumed; predicted probability)

. egen prmax = rmax(pr1 pr2 pr3) 

. forval i= 1/3 {
  2.         replace pcr = `i' if pr`i'==prmax
  3.                 }
(65 real changes made)
(81 real changes made)
(48 real changes made)

. tab pcr pctstck 

           | 0=mstbnds,50=mixed,100=mststcks
       pcr |         0         50        100 |     Total
-----------+---------------------------------+----------
         1 |        33         21         11 |        65 
         2 |        25         31         25 |        81 
         3 |         6         20         22 |        48 
-----------+---------------------------------+----------
     Total |        64         72         58 |       194 


. * Percentages correctly predicted
. di "Mostly bonds =   " 33/64 * 100
Mostly bonds =   51.5625

. di "Mixed =   " 31/72 * 100
Mixed =   43.055556

. di " Mostly stocks =  " 22/58 * 100
 Mostly stocks =  37.931034

. di "Overall %age correctly predicted =   " (33+31+22)/194  
Overall %age correctly predicted =   .44329897


. log close 
      name:  SN
       log:  iiexample16.smcl
  log type:  smcl
 closed on:  11 May 2020, 08:09:52
------------------------------------------------------------------------------------------