Announcement

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

  • mimrgns and marginsplot; plotting exponentiated predictions?

    Hello, I am currently trying to make a graph using marginsplot after the mimgrns command. I am having trouble getting marginsplot to use the exponentiated predictions on the y-axis. My code is as follows:

    Code:
    mi estimate, eform: ///
        logit ALC_ c.MED_ c.ADHD_ c.DEP_ AGE i.WAVE i.SEX i.ETHNIC i.FAMHIST_ALC i.FAMHIST_DRUG i.WAVE i.LUNCH, or vce(cluster SCHOOL)
    mimrgns, at(MED_=(0(1)42)) atmeans eform cmdmargins
    marginsplot, ///
        recast(line) ///
        recastci(rarea) ///
        ciopts(fintensity(30) ///
        lwidth(none)) ///
        yla(-4(1)4, ang(h)) ///
        xtitle("Social Media Score", size(small)) ///
        ytitle("Probability of Initiating Alcohol Use", size(small)) ///
        title("Probability of Initiating Alcohol Use, by Social Media Score") ///
        subtitle("Overall Sample") ///
        saving(GRAPH_overall, replace)
    graph export GRAPH_overall.pdf, replace
    I've attached a PDF of the graph I get. It looks good, except that I want the y-axis to be predicted probabilities, and right now I think these are on the log scale. I tried adding the eform option to mimrgns but marginsplot afterward still plots the un-exponentiated values. Is there anyway around this, either with another command, or some way of exporting these values to a separate dataset to plot independently of marginsplot? Thank you in advance for any help that can be offered.

    (Also, I have read the online help file for mimrgns and understand that the CIs plotted with marginsplot are not correct.)
    Attached Files

  • #2
    mimrgns is community-contributed software from SSC.

    I find it a bit hard to figure out what exactly you want. You say

    Originally posted by Kira Riehm View Post
    I am having trouble getting marginsplot to use the exponentiated predictions

    but then

    Originally posted by Kira Riehm View Post
    I want the y-axis to be predicted probabilities
    Those are not the same thing! Exponentiated log-odds are odds (ratios), not probabilities. If you want the latter, you will have to explicitly request that, As the help file for mimrgns explains, it defaults to predicting xb. You may overwrite that

    Code:
    mimrgns ... , predict(pr)
    Best
    Daniel

    Comment


    • #3
      Thanks for your help Daniel - this clarifies multiple issues on my end, and I got the graph to work!

      Best,

      Kira

      Comment


      • #4
        Hi daniel klein or others,

        I'm interested in Dr. Riehm's original question, which is how to have marginsplot plot exponentiated predicted margins after mimrgns. I'm working with negative binomial regression and log-linear regression, both of which I would like to plot in exponentiated form. The option eform works with mimrgns to display exponentiated values (as does expression(exp(predict(xb))), however marginsplot still plots the non-transformed predicted values.

        My work around has been to exponentiate the values and plot in R, though would appreciate a more direct route.

        Thanks,
        Luke

        Comment


        • #5
          Originally posted by Luke Aldridge View Post
          The option eform works with mimrgns to display exponentiated values
          Yes, it does; the eform option, however, only affects how coefficients are displayed in the table; it is probably of little use here.


          Originally posted by Luke Aldridge View Post
          [...] as does expression(exp(predict(xb))), however marginsplot still plots the non-transformed predicted values.
          Can you provide a reproducible example? Specifying expression() with mimrgns clearly produces a different graph from the default predictions in the following example:

          Code:
          // example dataset
          webuse mheart1s20
          
          mi estimate : logit attack bmi i.female
          
          // marginsplot with non-transfomed prediction
          mimrgns , cmdmargins
          marginsplot
          
          // now with transfomred predictions
          mimrgns , expression(exp(predict(xb))) cmdmargins
          marginsplot
          Whether that is what you want, is a different question.

          Comment

          Working...
          X