Announcement

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

  • Coefplot Question

    Hi All,

    I am struggling with finding a way to have separate connected lines for each model in one figure. If you have any suggestion, please help if you can. below is an example. Thank you so much!

    sysuse auto

    regress price ib12.mpg if foreign==0
    estimates store domestic
    regress price ib12.mpg if foreign==1
    estimates store foreign

    coefplot domestic foreign, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid) addplot(scatter @b @at, connect(l))


    I can do it using the code below, but I need it in one figure:

    coefplot domestic || foreign, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid) addplot(scatter @b @at, connect(l))




  • #2
    HTML Code:
    https://www.statalist.org/forums/forum/general-stata-discussion/general/508990-coefplot-with-multiple-models
    Simplest variant:

    coefplot (domestic) || (foreign)

    Comment


    • #3
      Originally posted by Renee Dobbs View Post
      Hi All,

      I am struggling with finding a way to have separate connected lines for each model in one figure. If you have any suggestion, please help if you can.
      coefplot is from SSC (FAQ Advice #12). Thanks for providing a reproducible example on your very first post. Note that -connected- is a twoway plot type, so you can just use the option -recast()- to get what you want.

      Code:
      sysuse auto, clear
      regress price ib12.mpg if foreign==0
      estimates store domestic
      regress price ib12.mpg if foreign==1
      estimates store foreign
      set scheme s1color
      coefplot domestic foreign, drop(_cons) vertical xlabel(, angle(45) labsize(small) grid) recast(connected)
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	55.8 KB
ID:	1727305

      Comment


      • #4
        Thanks a lot for the replies George and Andrew. Andrew Musau, that's exactly what I was looking for. I also want to thank you for your massive contributions to this forum. I have solved countless Stata coding problems for years using your replies and contributions to Statalist. From all of us, who have silently benefited from your many years of selfless service to Stata users all over the world, simply THANK YOU!

        Comment


        • #5
          Thank you Renee Dobbs for your kind words!

          Comment


          • #6
            I'm learning as much as I'm giving, especially from guys like Andrew (who magically turns 10 lines of code into 1).

            Comment

            Working...
            X