Announcement

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

  • Visualizing predicted probabilities for each category of ethnicity by dependent variable categories in mlogit model

    I am running an mlogit model for survey data and trying to figure out the best way to visualize the predicted probabilities for each category of the IV “ethnicity” for each of the 5 categories of the dependent variable ("candidates"). When I do margins and run “marginsplot” after, the X axis is the categories of ethnicity. I want to visualize it so that I can compare the categories of ethnicity for each of the dependent variables. For example, make the x dimension each category of the dependent variable. Thank you in advance.

    svy: mlogit candidates i.ethnicity age male educ income, baseoutcome(1)
    margins ethnicity, predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) predict(outcome(4)) predict(outcome(4))
    marginsplot

  • #2
    The easiest way to get the graph you want from margins is to save the marginal effects results and then iterate on the graph using the saved results. See code below for an example that may or may not be similar to your case.
    Code:
    webuse sysdsn1, clear
    tab male nonwhite
    mlogit insure age i.male##i.nonwhite i.site
    margins male#nonwhite, saving(test)
    
    clear
    use test.dta
    gen gender_race = 0 if _m1==0 & _m2==0        // female, non-white
    replace gender_race = 1 if _m1==0 & _m2==1     // male, non-white
    replace gender_race = 2 if _m1==1 & _m2==0    // female, white
    replace gender_race = 3 if _m1==1 & _m2==1     // male, white
    label define gen_race 0 "female, non-white" 1 "male, non-white" ///
        2 "female, white" 3 "male, white"
    label values gender_race gen_race
    
    twoway rspike _ci_ub _ci_lb gender_race || scatter _margin gender_race, ytitle("Predicted probability") xtitle("Gender and Race") legend(off) xla(, valuelabel)
    The challenge I have with this graph is that, as a naïve reader, I don't understand why there are three parameters estimated for each group. You would have to explain that very well in text or somehow indicate it in a legend or otherwise on the graph.

    Comment

    Working...
    X