Announcement

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

  • coefplot after mlogit

    Hello,

    This is my first post so hopefully, I will get it right.

    I run mlogit and would like to use coefplot (from ssc) to show my outcome. My dependent variable (decoupling) contains 4 categories.

    What I currently get is a long graph with the three categories one beneath the other. What I would like to get is a graph with the three categories side-by-side. In fact, if it makes sense, having all four categories (including the based one) would be ideal. If someone knows how to do that, this will be much appreciated!

    Here is an example of my data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float decoupling long waves2 byte(urban educlvl husedlvl) float(edugap employment) byte(wealthq tv)
    3 1 0 1 0 2 1 1 0
    0 0 1 1 1 1 1 5 1
    1 . 0 0 1 0 0 4 0
    1 . 0 1 0 2 3 3 0
    3 0 0 0 0 1 2 2 0
    2 1 1 3 2 2 0 5 1
    0 1 0 2 2 1 1 2 1
    0 0 0 1 2 0 0 4 1
    0 1 0 0 1 0 2 2 0
    3 1 0 2 0 2 0 1 0
    3 0 0 2 2 1 0 5 1
    3 0 0 0 1 0 0 2 0
    0 1 0 2 2 1 0 1 0
    3 0 0 0 0 1 2 3 0
    0 1 1 3 3 1 1 5 1
    0 0 1 3 3 1 0 5 0
    1 . 0 0 . . 3 4 0
    1 . 0 2 2 1 0 3 0
    1 1 0 2 2 1 3 3 0
    1 0 0 0 1 0 0 4 1
    end
    label values decoupling decouplingl
    label def decouplingl 0 "Supports gender equity/Empowered in household", modify
    label def decouplingl 1 "Rejects gender equity/Empowered in household", modify
    label def decouplingl 2 "Supports gender equity/Not empowered in household", modify
    label def decouplingl 3 "Rejects gender equity/Not empowered in household", modify
    label values waves2 waves2
    label def waves2 0 "first wave", modify
    label def waves2 1 "second wave", modify
    label values urban urbanl
    label def urbanl 0 "rural", modify
    label def urbanl 1 "urban", modify
    label values educlvl EDUCLVL
    label def EDUCLVL 0 "no education", modify
    label def EDUCLVL 1 "primary", modify
    label def EDUCLVL 2 "secondary", modify
    label def EDUCLVL 3 "higher", modify
    label values husedlvl HUSEDLVL
    label def HUSEDLVL 0 "no education", modify
    label def HUSEDLVL 1 "primary", modify
    label def HUSEDLVL 2 "secondary", modify
    label def HUSEDLVL 3 "higher", modify
    label values edugap edugapl
    label def edugapl 0 "less", modify
    label def edugapl 1 "equal", modify
    label def edugapl 2 "more", modify
    label values employment employmentl
    label def employmentl 0 "doesn't work", modify
    label def employmentl 1 "all year", modify
    label def employmentl 2 "seasonally", modify
    label def employmentl 3 "occasionlly", modify
    label values wealthq WEALTHQ
    label def WEALTHQ 1 "poorest", modify
    label def WEALTHQ 2 "poorer", modify
    label def WEALTHQ 3 "middle", modify
    label def WEALTHQ 4 "richer", modify
    label def WEALTHQ 5 "richest", modify
    label values tv tv
    label def tv 0 "no", modify
    label def tv 1 "yes", modify
    And here is the code that I am using
    Code:
    mlogit decoupling waves2 urban i.educlvl i.husedlvl i.edugap i.employment i.wealthq tv, rrr
    estimates store m1
    coefplot m1, drop(_cons) keep(*:) scheme(s1mono)
    And the graph that I currently get:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	119.5 KB
ID:	1598258


    Thank you in advance!

  • #2
    coefplot is from the Stata Journal. Thanks for the reproducible example. I would use margins to obtain results pertaining to each category and then plot these. Here is a sketch.

    Code:
    mlogit decoupling waves2 urban i.educlvl i.husedlvl i.edugap i.employment i.wealthq tv, rrr
    estimates store m1
    margins, dydx(*) predict(outcome(2) xb) post
    est sto m2
    est restore m1
    margins, dydx(*) predict(outcome(3) xb) post
    est sto m3
    coefplot m2 || m3, drop(_cons)

    Comment


    • #3
      Thank you, Andrew, for your suggestion. I used a similar approach when I was interested in the predicted probabilities. In that case, I used marginsplot and graph combine. I may try coefplot for this in the future.

      Here, however, I was interested in the actual relative risk ratio (rrr) of the whole model. Thanks to the courtesy of Ben Jann, I now have the solution I was looking for. What is needed is to select the equations as separate series. With his permission, I am pasting here the examples he provided me:

      Code:
      webuse sysdsn1, clear
      mlogit insure age male nonwhite i.site
      coefplot (., keep(Prepaid:)) (., keep(Uninsure:)), drop(_cons)
      Or if you want the equations in different subgraphs:
      Code:
      coefplot ., keep(Prepaid:)  bylabel(Prepaid)  || ///
               ., keep(Uninsure:) bylabel(Uninsure) ||, drop(_cons)
      Or two models using multiple series in multiple subgraphs:
      Code:
      mlogit insure age male nonwhite
      est sto m1
      mlogit insure age male nonwhite i.site
      est sto m2
      coefplot (m1) (m2), keep(Prepaid:)  bylabel(Prepaid)   || ///
               (m1) (m2), keep(Uninsure:) bylabel(Uninsure) || ///
               , drop(_cons) plotlabels("Model 1" "Model2")

      Comment


      • #4
        Thanks for posting Ben's solution. Note that you can get RRRs with margins as well, but Ben's solution is better as it directly uses the mlogit results.

        Comment

        Working...
        X