Announcement

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

  • How can I overlap two marginsplot graph???

    Hi. I always thanks to statalist.

    I have six years of cross sectional data for SBP and BMI.

    There are three variables, SBP, BMI and Year.

    I would like to draw the SBP's average trend graph over the years before and after the adjustment to BMI.

    How can I overlay the two graphs below?

    reg sbp bmi i.year
    margins year
    marginsplot

    reg sbp i.year
    margins year
    marginsplot

    like this graph
    Click image for larger version

Name:	aaaa.png
Views:	1
Size:	103.6 KB
ID:	1514800

  • #2
    Consider using Nicholas Winter's user-written ado program -combomarginsplot-
    Code:
    findit combomarginsplot
    Also see Nicholas Winter's workaround alternative for the limits of -combomarginsplot- in post #3 at:

    https://www.statalist.org/forums/for...gle-regression

    Good luck.

    Red Owl
    Stata/IC 16 (Windows 10, 64-bit)

    Comment


    • #3
      So, give each of the -marginsplot-s a name, by adding the -name()- option to each -marginsplot- command. And then use -graph combine-. See -help name_option- and -help graph combine- for more details.

      Added: Crossed with #2.

      Comment


      • #4
        Originally posted by Red Owl View Post
        Consider using Nicholas Winter's user-written ado program -combomarginsplot-
        Code:
        findit combomarginsplot
        Also see Nicholas Winter's workaround alternative for the limits of -combomarginsplot- in post #3 at:

        https://www.statalist.org/forums/for...gle-regression

        Good luck.

        Red Owl
        Stata/IC 16 (Windows 10, 64-bit)
        Thank you very much Red Owl, Clyde Schechter
        Best

        Comment


        • #5
          post deleted
          Last edited by Cristiano Bellavitis; 03 May 2022, 11:45.

          Comment

          Working...
          X