Announcement

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

  • How can I plot the contrasts between margin estimates instead of the margin estimates in a logistic regression?

    Hi all,

    I have a quite straightforward question: I am interested in the effects of a treatment in several variables, for that I need to run a series of regressions adjusting for certain variables, see:

    Code:
    logit outcome treatment control1 control2 control3
    
    margins treatment, pwcompare
    Normally if I wanted to plot the margins I would the proceed with something like this:

    Code:
    marginsplot, xlabel(1 "Group 1" 2 "Group 2" 3 "Group 3") ///
        ytitle("Proportion (Adjusted)") ///
        title("Adjusted Proportions by Treatment Group") ///
        plotopts(msymbol(circle) mcolor(blue)) ///
        ciopts(lcolor(blue))
    But because I am interested in visualising if there are differences across treatment groups I need to plot the contrasts:

    Click image for larger version

Name:	Screenshot 2025-01-18 091645.png
Views:	1
Size:	24.3 KB
ID:	1771008


    When using the previous marginsplot command I do not get what ideally I want: In one axis the three comparisons 1 vs 2; 2 vs 3 and 1 vs 3 and in the otger axis the three coressponding contrasts with their CI.

    Is there a way to plot this or not at all?

    Thank you so much for your attention.



  • #2
    https://www.stata.com/manuals/rmargi...isecomparisons

    The example on page 26 should cover your case.
    Best wishes

    (Stata 16.1 MP)

    Comment

    Working...
    X