Announcement

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

  • Using coefplot to plot a combined graph

    Hi all,

    I would like to generate a graph similar to the attached image, where I plot estimates from several groups together. I'm currently not sure how I can combine several categories and subcategories together as done here. Any example code would be very helpful.

    Many thanks,
    Ashani
    Click image for larger version

Name:	fig.png
Views:	1
Size:	70.2 KB
ID:	1750111

  • #2
    coefplot is from SSC, as you are asked to explain in FAQ Advice #12. You need to add context to your question. What commands are you running? Are the coefficients from one or several regressions? The best way to do this is to provide a reproducible example as recommended in the aforementioned FAQ Advice.

    Comment


    • #3
      Hi Andrew,

      Thanks for your response. Below is the code I tried so far:

      Code:
      matrix input A = (0, 0.018, -0.063, -0.009 \ 0, 0.020, 0.038, 0.054)
      matrix input B = (0, 0.024, -0.092, -0.219 \ 0, 0.026, 0.053, 0.071)
      coefplot mat(A) mat(B), se(2) vertical yline(0, lcolor(gray)) xlab(1 "Base" 2 "Pre" 3 "Post1" 4 "Post2") title("Real income", size(*0.90) color(navy)) ciopts(lcolor(navy) recast(rcap)) format(%9.2f) mlabposition(12) mlabgap(*2) mlabel(cond(@pval<.01, string(@b, "%9.3fc") + "***", cond(@pval<.05, string(@b, "%9.3fc") + "**", cond(@pval<.10, string(@b, "%9.3fc") + "*", string(@b, "%9.3fc"))))) mlabcolor(navy) color(navy) graphregion(col(white)) bgcol(white) xlab(, nogrid) ylab(, nogrid)
      I would like to refine it further to rename A as 'Real income' and B as 'Real wages', and denote them by different symbols along with a legend, as done in the image in #1.

      Comment


      • #4
        Code:
        matrix input A = (0, 0.018, -0.063, -0.009 \ 0, 0.020, 0.038, 0.054)
        matrix input B = (0, 0.024, -0.092, -0.219 \ 0, 0.026, 0.053, 0.071)
        coefplot (mat(A), label("Real Income") ms(Oh)) (mat(B), label("Real Wages") ms(T)), se(2) vertical yline(0, lcolor(gray)) xlab(1 "Base" 2 "Pre" 3 "Post1" 4 "Post2") title("Real income", size(*0.90) color(navy)) ciopts(lcolor(navy) recast(rcap)) format(%9.2f) mlabposition(12) mlabgap(*2) mlabel(cond(@pval<.01, string(@b, "%9.3fc") + "***", cond(@pval<.05, string(@b, "%9.3fc") + "**", cond(@pval<.10, string(@b, "%9.3fc") + "*", string(@b, "%9.3fc"))))) mlabcolor(navy) color(navy) graphregion(col(white)) bgcol(white) xlab(, nogrid) ylab(, nogrid)
        Res.:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	41.7 KB
ID:	1750208

        Comment


        • #5
          Thanks very much Andrew, this is very helpful.

          Can you please let me know what 'ms(Oh)' and 'ms(T)' refer to? If I need to add more components, how would I adjust this accordingly?

          Comment


          • #6
            I figured this out, thank you.

            Comment

            Working...
            X