Announcement

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

  • margins and graph bar

    Hello. Is there a way to use the estimates from the margins command with graph bar?

    **I recognize that mlogit is not the appropriate method to use here, but I am using it for illustrative purposes since I am using mlogit**

    Code:
    use http://www.stata-press.com/data/r13/nhanes2f, clear
    svyset psuid [pweight=finalwgt], strata(stratid)    
    qui: svy, subpop(if race==1): mlogit health i.sex
    margins sex
    
    Adjusted predictions                            Number of obs     =     10,335
    Model VCE    : Linearized
    
    1._predict   : Pr(health==poor), predict(pr outcome(1))
    2._predict   : Pr(health==fair), predict(pr outcome(2))
    3._predict   : Pr(health==average), predict(pr outcome(3))
    4._predict   : Pr(health==good), predict(pr outcome(4))
    5._predict   : Pr(health==excellent), predict(pr outcome(5))
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _predict#sex |
         1#Male  |   .0447356   .0049345     9.07   0.000     .0346717    .0547996
       1#Female  |   .0384132   .0047268     8.13   0.000     .0287729    .0480535
         2#Male  |   .1026698   .0058075    17.68   0.000     .0908253    .1145143
       2#Female  |   .1278347   .0053382    23.95   0.000     .1169474    .1387219
         3#Male  |   .2582044   .0069776    37.00   0.000     .2439734    .2724354
       3#Female  |    .279219   .0090939    30.70   0.000     .2606719    .2977661
         4#Male  |   .2838719   .0086906    32.66   0.000     .2661472    .3015966
       4#Female  |   .2859271   .0077648    36.82   0.000     .2700908    .3017635
         5#Male  |   .3105183   .0086544    35.88   0.000     .2928675    .3281691
       5#Female  |   .2686059   .0101683    26.42   0.000     .2478676    .2893443
    ------------------------------------------------------------------------------
    
    graph bar, over(health) over(sex) asyvar percent stack ///
        blabel(bar, pos(center) format(%9.0f) color(white) size(vsmall))
    Results:

    Click image for larger version

Name:	Graph.png
Views:	2
Size:	45.9 KB
ID:	1727262


    You can see that the results that the results on the graph do not match the estimates from the margins.

    Thank you!
    Pina
    Attached Files

  • #2
    HTML Code:
    https://www.statalist.org/forums/forum/general-stata-discussion/general/1316500-using-margins-plot-to-create-bar-graphs

    Comment


    • #3
      Hi guys,

      I have a question regarding ploting of elasticities of individual cross sections in a single stata graph.

      reg lnTFP lnEU, robust
      margins, eyex(lnEU)
      marginsplot, xline(0) xtitle("name") ytitle("name")

      This command gives a elasticity plot with a confidence interval. However, how can I plot the elasticity for each of my cross-sections? I have 17 cross-sections. The cross-section variable is named as ID. Further, let's say I divide the cross sections into two categories such as RDE and RDW (both are dummy variables, giving the value of 1 to countries that belong to a particular region and zero otherwise). What can be the commands for plotting individual elasticities in a single graph and then dividing the countries' plots according to the RDE and RDW?

      Comment

      Working...
      X