Announcement

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

  • Etable after margins: specifying column tables

    I would like to report the marginal effects after mlogit. Using the following code, etable produces a nice table. However, the columns showing marginal effects for outcomes 1 and 3 are labeled m_1 and m_3. (When I use the option columns(index) they are labeled 1 and 2.) How can I get more informative column labels, possibly the labels on the dependent variable?

    Thanks,
    Devra

    Code:
    clear
    webuse sysdsn1
    tab insure
    
    mlogit insure age i.male i.nonwhite i.site, rrr coeflegend
    est store m
    est res m
    
    forval i = 1/3 {
     margins, dydx(*) predict(outcome(`i')) post
    estimates store m_`i'
    estimates restore m
    }
    
    
    etable, estimates(m_1 m_3 ) ///
     cstat(_r_b, nformat(%9.3g)) cstat(_r_z, nformat(%9.3g)) ///
     showstars column(estimates)
    Devra Golbe
    Professor Emerita, Dept. of Economics
    Hunter College, CUNY

  • #2
    From

    Code:
    help etable
    the only possibilities are:

    column_header Description
    -------------------------------------------------------------------------------------------------------------------------------------------
    depvar show dependent variable name; the default
    dvlabel show variable label for dependent variable
    command show command name
    title show command title
    estimates show estimates name
    index show result set index
    -------------------------------------------------------------------------------------------------------------------------------------------
    So the only route that I see is to name the estimates with the corresponding value label.


    Code:
    clear
    webuse sysdsn1
    tab insure
    
    mlogit insure age i.male i.nonwhite i.site, rrr coeflegend
    est store m
    est res m
    
    forval i = 1/3 {
        margins, dydx(*) predict(outcome(`i')) post
        estimates store `:lab (insure) `i''
        estimates restore m
    }
    
    
    etable, estimates(`:lab (insure) 1' `:lab (insure) 3') ///
    cstat(_r_b, nformat(%9.3g)) cstat(_r_z, nformat(%9.3g)) ///
    showstars column(estimates)
    You could extract the label from e() after margins, but the above works well.

    Res.:

    Code:
    . etable, estimates(`:lab (insure) 1' `:lab (insure) 3') ///
    >  cstat(_r_b, nformat(%9.3g)) cstat(_r_z, nformat(%9.3g)) ///
    >  showstars column(estimates)
    
    --------------------------------------------------
                                 Indemnity   Uninsure
    --------------------------------------------------
    NEMC (ISCNRD-IBIRTHD)/365.25 .00267    -.000151  
                                   1.91       -.206  
    NEMC PATIENT MALE                                
      1                            -.13 **    .0118  
                                  -2.87        .474  
    nonwhite                                          
      1                           -.203 **   -.0188  
                                  -4.21        -.81  
    site                                              
      2                           .0071      -.0679 **
                                   .148       -2.82  
      3                            .122 *    .00482  
                                    2.4        .153  
    Number of observations          615         615  
    --------------------------------------------------

    Comment


    • #3
      Thanks Andrew. Exactly what I wanted!
      Devra Golbe
      Professor Emerita, Dept. of Economics
      Hunter College, CUNY

      Comment


      • #4
        I have a related question:
        With the help of this post, I learned about the etable command. Thank you so much!

        However, when I run the etable command, the results for my two treatments (housing and pledge) are reported below each other. But the margins for each are reported twice next to each other. How can I fix this? Below I have provided my code as well as the table. I am using Stata 18.


        Code:
        .mlogit treatment hh_size hh_adult tired i.city
        margins, dydx(*) predict(outcome(2))
        eststo m_housing
        margins, dydx(*) predict(outcome(3))
        eststo m_pledge
        etable, estimates(m_housing m_pledge) column(estimates) showstars export(Table2.tex, replace)
        
        -----------------------------------------------------------
                                               m_housing  m_pledge 
        -----------------------------------------------------------
        1=Medellín 2=Cali 3=Baranquilla                            
          Cali                                 -0.368     -0.368   
                                              (0.207)    (0.207)   
          Barranquilla                         -0.343     -0.343   
                                              (0.208)    (0.208)   
        HH Size                                 0.171 *    0.171 * 
                                              (0.084)    (0.084)   
        No. of Adults in HH                    -0.237 *   -0.237 * 
                                              (0.119)    (0.119)   
        Frequency of Feeling Physically Tired   0.333 **   0.333 **
                                              (0.079)    (0.079)   
        Intercept                              -1.198 **  -1.198 **
                                              (0.317)    (0.317)   
        1=Medellín 2=Cali 3=Baranquilla                            
          Cali                                 -0.122     -0.122   
                                              (0.203)    (0.203)   
          Barranquilla                         -0.283     -0.283   
                                              (0.211)    (0.211)   
        HH Size                                 0.227 **   0.227 **
                                              (0.080)    (0.080)   
        No. of Adults in HH                    -0.097     -0.097   
                                              (0.111)    (0.111)   
        Frequency of Feeling Physically Tired   0.182 *    0.182 * 
                                              (0.077)    (0.077)   
        Intercept                              -1.347 **  -1.347 **
                                              (0.313)    (0.313)   
        Number of observations                    876        876   
        -----------------------------------------------------------
        Thanks already!

        Comment


        • #5
          Charles,

          Does adding post to your margins commands help?
          Code:
           
           margins, dydx(*) predict(outcome(2)) post
          Devra Golbe
          Professor Emerita, Dept. of Economics
          Hunter College, CUNY

          Comment


          • #6
            It helps when we have public use data to go with the code.

            In the following I use an example from the mlogit help file.
            Code:
            webuse sysdsn1
            
            mlogit insure age male nonwhite i.site
            
            * compute all marginal effects of interest
            
            margins, dydx(*) predict(outcome(2)) predict(outcome(3))
            
            * look at how -margins- stripes the marginal effects
            
            matrix list r(b)
            
            * use -margins- option to tell -etable- to collect from its -r()-
            * results; also use option -showeq- since the equations in -r(b)- from
            * the -margins- command correspond with the x-variables in the fitted
            * model and we want to see them in the row headers
            
            etable, showstars margins showeq
            
            * use -collect layout- to see the table's row and column specifications
            
            collect layout
            
            * remap the prediction indices back to the outcome levels
            
            collect remap colname[1._predict 2._predict] = colname[2.insure 3.insure]
            
            * make sure to show the outcome's variable and value labels
            
            collect style header insure, title(label) level(label)
            
            * arrange the items as you like
            
            collect layout (coleq#result[_r_b _r_se]) (colname#stars)
            Here is the final table.
            Code:
            --------------------------------------------------
                                           Type of insurance
                                           Prepaid   Uninsure
            --------------------------------------------------
            NEMC (ISCNRD-IBIRTHD)/365.25  -0.003     -0.000
                                         (0.001)    (0.001)
            NEMC patient male              0.118 **   0.012
                                         (0.045)    (0.023)
            Nonwhite                       0.222 **  -0.016
                                         (0.050)    (0.026)
            Site of study
              2                            0.061     -0.068 **
                                         (0.048)    (0.024)
              3                           -0.126 *    0.005
                                         (0.049)    (0.031)
            --------------------------------------------------

            Comment


            • #7
              Thanks! Very helpful.
              Devra Golbe
              Professor Emerita, Dept. of Economics
              Hunter College, CUNY

              Comment


              • #8
                Dear Jeff, that is amazing! Thank you so much!

                Comment

                Working...
                X