Announcement

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

  • Export predicted probabilities of an interaction effect in mlogit to Excel

    Dear members of the list,

    After a multinomial logit model, I am interested in extracting the predicted probabilities corresponding to one my key independent variables for the categories of another independent variable; that is, in the predicted probabilities corresponding to an interaction effect between two independent variables in my model. I am particularly interested in these predicted probabilities for one of the possible outcomes in the multinomial logit model.

    Code:
    margins var.indep1#var.indep2 , predict(outcome(Work)) post
    First, I use estimates store....

    Code:
    estimates store ocup_fos_work
    ...and then esttab to extract the predicted probabilities to an csv file

    Code:
    . esttab using myfile.csv,  se label nolines replace
    I have simplified my path and my code, but the result in Stata is something as follows:

    HTML Code:
    . margins codi_a2#ocu_parents if codi_a2<6, predict(outcome(Work)) post
    
    Predictive margins                                      Number of obs = 33,312
    Model VCE: OIM
    
    Expression: Pr(expect3==Work), predict(outcome(Work))
    
    -----------------------------------------------------------------------------------------------------
                                        |            Delta-method
                                        |     Margin   std. err.      z    P>|z|     [95% conf. interval]
    ------------------------------------+----------------------------------------------------------------
                    codi_a2#ocu_parents |
      Humanities#Elementary/never work  |   .1231373   .0232878     5.29   0.000      .077494    .1687806
                  Humanities#Unskilled  |   .1767854   .0434439     4.07   0.000     .0916369    .2619338
                    Humanities#Skilled  |    .105484   .0273348     3.86   0.000     .0519087    .1590593
            Humanities#Small employers  |   .0972449   .0190566     5.10   0.000     .0598946    .1345952
                    Humanities#Service  |   .0938936   .0133487     7.03   0.000     .0677305    .1200566
                     Humanities#Clerks  |   .1279894   .0160328     7.98   0.000     .0965657    .1594131
                Humanities#Ass.Profess  |   .1443823   .0212913     6.78   0.000     .1026521    .1861125
           Humanities#Profess Managers  |   .0963129   .0100046     9.63   0.000     .0767041    .1159216
       Social Sc#Elementary/never work  |   .2325878   .0129943    17.90   0.000     .2071195    .2580561
                   Social Sc#Unskilled  |   .2233837   .0201639    11.08   0.000     .1838631    .2629042
                     Social Sc#Skilled  |   .2458289     .01904    12.91   0.000     .2085112    .2831467
             Social Sc#Small employers  |   .2170858   .0122917    17.66   0.000     .1929946     .241177
                     Social Sc#Service  |   .2187633   .0089836    24.35   0.000     .2011558    .2363709
                      Social Sc#Clerks  |   .1917011   .0092521    20.72   0.000     .1735674    .2098348
                 Social Sc#Ass.Profess  |   .1906258   .0106476    17.90   0.000     .1697569    .2114947
            Social Sc#Profess Managers  |   .1667551   .0056803    29.36   0.000      .155622    .1778882
    Nat Sciences#Elementary/never work  |   .1091409   .0235161     4.64   0.000     .0630502    .1552317
                Nat Sciences#Unskilled  |   .1619883   .0424369     3.82   0.000     .0788135    .2451631
                  Nat Sciences#Skilled  |   .1654063   .0398721     4.15   0.000     .0872583    .2435543
          Nat Sciences#Small employers  |   .1187532   .0208774     5.69   0.000     .0778343    .1596721
                  Nat Sciences#Service  |   .1110627   .0151574     7.33   0.000     .0813548    .1407706
                   Nat Sciences#Clerks  |   .1024714   .0129927     7.89   0.000     .0770063    .1279366
              Nat Sciences#Ass.Profess  |   .0909274   .0152161     5.98   0.000     .0611044    .1207504
         Nat Sciences#Profess Managers  |   .0829258   .0075252    11.02   0.000     .0681767     .097675
      Health Sc.#Elementary/never work  |   .2113802   .0209426    10.09   0.000     .1703334    .2524269
                  Health Sc.#Unskilled  |   .2328505   .0323976     7.19   0.000     .1693523    .2963486
                    Health Sc.#Skilled  |   .2340141   .0272348     8.59   0.000      .180635    .2873933
            Health Sc.#Small employers  |   .1991124   .0168673    11.80   0.000     .1660532    .2321716
                    Health Sc.#Service  |   .2110933   .0136454    15.47   0.000     .1843489    .2378377
                     Health Sc.#Clerks  |   .2095122   .0129883    16.13   0.000     .1840556    .2349688
                Health Sc.#Ass.Profess  |   .1901181    .014732    12.91   0.000     .1612439    .2189924
           Health Sc.#Profess Managers  |   .2137041   .0072126    29.63   0.000     .1995678    .2278404
    Engin. Arqui#Elementary/never work  |   .2389631   .0200133    11.94   0.000     .1997378    .2781885
                Engin. Arqui#Unskilled  |   .2529068    .030537     8.28   0.000     .1930555    .3127582
                  Engin. Arqui#Skilled  |   .2764256   .0265191    10.42   0.000      .224449    .3284021
          Engin. Arqui#Small employers  |   .2200667   .0170406    12.91   0.000     .1866678    .2534657
                  Engin. Arqui#Service  |   .2438614   .0138371    17.62   0.000     .2167413    .2709816
                   Engin. Arqui#Clerks  |   .2046769    .011521    17.77   0.000     .1820961    .2272576
              Engin. Arqui#Ass.Profess  |   .1846245   .0129246    14.28   0.000     .1592927    .2099563
         Engin. Arqui#Profess Managers  |   .1503262   .0063353    23.73   0.000     .1379092    .1627431
    -----------------------------------------------------------------------------------------------------
    My apologies for the length of the output. My question comes next.

    How could I manage to take these predicted probabilities to Excel so that each category in one of the independent variables in the interaction (say, field of studies, which is the first one) is placed in one column... and the other variable (parental occupation) in the rows? This would greatly help me in arranging my tables, but, in spite of my search in Statalist and in the esttab help menu (especially layout option), I do not manage to get the answer.

    Thanks for your attention

    And kind regards

    Luis Ortiz
    Last edited by Luis Ortiz; 17 Apr 2023, 11:16.
Working...
X