Announcement

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

  • Help appreciated! Marginsplot for my dissertation.

    Hi! I'm currently trying to generate a graph using marginsplot for my dissertation, to display how a treatment (exposure to the news of a US Supreme Court ruling) affects my outcome variable (European perceptions of the US). I have a treatment variable coded as 0=control group (interviewed before the court ruling) and 1=treatment group (interviewed after the court ruling). I'm trying to generate three graphs displaying the 95% CI for 1. the overall effect, 2. differences according to gender, and 3. differences according to political affiliation. I want it to look like this:

    Click image for larger version

Name:	IMG_CDFE3E7C298C-1.jpeg
Views:	1
Size:	310.4 KB
ID:	1751088


    I've managed to create the middle graph (gender differences) and third graph (political affiliation) using this command:

    logit USperception i.treatment##i.sex, rob
    margins treatment, at(sex=(0 1))
    marginsplot, recast(scatter)

    logit USperception i.treatment##i.leftright, rob
    margins treatment, at(leftright=(1 2 3))
    marginsplot, recast(scatter)

    However, the graph for the overall effect comes out like this (see below), splitting up the control and treatment group on two different lines on the x-axis instead of a red and blue CI on the same "line". I want them to be on the same "line" (as the picture above) so the results are easier to interpret next to the other two graphs.


    Click image for larger version

Name:	STATAgraphwrong.png
Views:	2
Size:	71.1 KB
ID:	1751090

    For this graph, I used the command:
    logit USperception i.treatment, robust
    margins treatment
    marginsplot, recast(scatter)

    If someone knows the right command for making the graph look like the one I have sketched, please let me know! Any help would be appreciated
    Attached Files

  • #2
    Code:
    margins treatment
    marginsplot, recast(scatter) plotdim(treatment)
    On an unrelated note, check out a discussion on the robust variance estimator for unclustered logistic regression at this link: https://www.stata.com/support/faqs/s...nce-estimator/. It's advisable to avoid using it unless you have reason to believe that your model is misspecified.

    Comment


    • #3
      Yes, that's exactly what I was looking for, thank you so much!

      Comment

      Working...
      X