Announcement

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

  • Storing and appending marginal effects for successive mlogit models in a single matrix

    Dear members of the list,

    I am running a multinomial logit regression for each one of a series of countries. My dependent variable ('educa_3bis') has three categories, corresponding to three levels of educational attainment among the interviewees. My key independent variable ('edufath') has also three categories, capturing father's educational attainment. This is the model for Spain:

    PHP Code:
    mlogit educa_3bis i.edufath if cntryid==724 
    After running such a regression for one given country, I am interested in the marginal effect of each category of father's education for each one of the outcomes in the dependent variable.

    PHP Code:
    margins edufather 
    Code:
    Predictive margins                              Number of obs     =      4,869
    Model VCE    : OIM
    
    1._predict   : Pr(educa_3bis==Less_than_university), predict(pr outcome(1))
    2._predict   : Pr(educa_3bis==Tertiary_BA), predict(pr outcome(2))
    3._predict   : Pr(educa_3bis==Tertiary_MA), predict(pr outcome(3))
    
    -------------------------------------------------------------------------------------------------------
                                          |            Delta-method
                                          |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------------------------------+----------------------------------------------------------------
                       _predict#edufather |
              1#ISCED 1, 2, and 3C short  |   .8425016   .0058787   143.31   0.000     .8309796    .8540236
    1#ISCED 3 (excluding 3C short) and 4  |   .5989692   .0205571    29.14   0.000      .558678    .6392604
                         1#ISCED 5 and 6  |   .3515469   .0225558    15.59   0.000     .3073383    .3957554
              2#ISCED 1, 2, and 3C short  |    .079534   .0043816    18.15   0.000     .0709462    .0881218
    2#ISCED 3 (excluding 3C short) and 4  |   .1729393   .0158741    10.89   0.000     .1418267    .2040519
                         2#ISCED 5 and 6  |   .2446958   .0204728    11.95   0.000     .2045698    .2848217
              3#ISCED 1, 2, and 3C short  |   .0779644   .0043496    17.92   0.000     .0694393    .0864895
    3#ISCED 3 (excluding 3C short) and 4  |   .2280915   .0176151    12.95   0.000     .1935664    .2626165
                         3#ISCED 5 and 6  |   .4037574   .0233377    17.30   0.000     .3580163    .4494984
    -------------------------------------------------------------------------------------------------------
    Moreover, I want to save these predictive margins in matrix, which I intend to do using xsvmat:

    PHP Code:
    matrix B r(b)
    xsvmat B, list(,) 
    Code:
    . xsvmat B, list(,)
    
         +-------------------------------------------------------------------------------------------------+
         |       B1         B2         B3        B4         B5         B6         B7         B8         B9 |
         |-------------------------------------------------------------------------------------------------|
      1. | .8425016   .5989692   .3515469   .079534   .1729393   .2446958   .0779644   .2280915   .4037574 |
         +-------------------------------------------------------------------------------------------------+
    But I do not want all the predictive margins in a single line, as it appears in the image above. Instead, I would like the matrix to consider father's education in rows and outcomes (dependent variables) in columns. Unfortunately, I do not know how to get the matrix in such way. Any help in this respect would be highly appreciated.

    Moreover, I would like such a matrix to be enriched with similar predictive margins generated after running identical models for the rest of countries in my list. For instance, I would like the predictive margins for Austria (next) to be appended to the matrix that I would eventually get for running the model for the previous country (Spain):

    PHP Code:
    mlogit educa_3bis i.edufath if cntryid==40 
    And to do the same with the rest of countries, so that I finally get a matrix with all the predictive probabilities for the three levels of father's education for all the countries together.

    Thanks for your attention and your help

    Luis Ortiz


Working...
X