Announcement

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

  • Headings for coefplot

    Hi All,

    I want to plot the coefficients of the 'post' variable for the following 6 regressions.

    Code:
    reg libindex time post treat if educ ==1 & (intyear > 1995 & intyear <2005) & age>24
    est store e1
    reg libindex time post treat if educ ==2 & (intyear > 1995 & intyear <2005) & age>24
    est store e2
    reg libindex time post treat if educ ==3 & (intyear > 1995 & intyear <2005) & age>24
    est store e3
    reg libindex time post treat if hhinc ==1 & (intyear > 1995 & intyear <2005) & age>24
    est store h1
    reg libindex time post treat if hhinc ==3 & (intyear > 1995 & intyear <2005) & age>24
    est store h2
    reg libindex time post treat if hhinc ==5 & (intyear > 1995 & intyear <2005) & age>24
    est store h3
    After that I run the following coefplot command:

    Code:
    coefplot (e1, aseq(Low educ) ///
            \ e2, aseq(Medium educ) ///
            \ e3, aseq(High educ) ///
            \ h1, aseq(Low inc) ///
            \ h2, aseq(Medium inc) ///
            \ h3, aseq(High inc)) ///
            ,  keep(post) swapnames xlabel(-0.6(0.1)0.1) xscale(range(-0.6(0.1)0.1))
    Click image for larger version

Name:	Bildschirm*foto 2024-04-19 um 18.47.45.png
Views:	1
Size:	571.5 KB
ID:	1750594


    I would like to add the header "Education" for the first three coefficients and "Income" for the next three. I cannot get it to work. Can someone help me?

    Thank you!

    All best,
    Hannah

  • #2
    coefplot is from SSC, as you are asked to explain (FAQ Advice #12). No need to separate the estimates using backslashes. You need to name grouped estimates the same to get what you want. For your future posts, present a reproducible example as recommended in the referenced FAQ Advice.

    Code:
    sysuse auto, clear
    replace weight= weight/100
    *ssc install estout, replace
    foreach var in disp gear length weight{
        eststo: regress `var' mpg i.rep78, robust
    }
    coefplot (est1, aseq(Engine))  (est2, aseq(Engine))   ///
    (est3, aseq(Size))  (est4, aseq(Size)), swapnames ///
     keep(mpg) ylab(, noticks labsize(4)) nokey

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	17.2 KB
ID:	1750611

    Comment


    • #3
      On the other hand, I may have misread your question in #1. If you wanted to just add group labels and keep the coefficient names, use the -group()- option.

      Code:
      sysuse auto, clear
      replace weight= weight/100
      estimates clear
      *ssc install estout, replace
      local i 1
      foreach var in disp gear length weight{
          rename mpg mpg`i'
          eststo: regress `var' mpg i.rep78, robust
          rename mpg`i' mpg
          local++i
      }
      
      coefplot est1 est2 est3 est4, ///
       keep(mpg*) ylab(, noticks labsize(4)) nokey ///
       groups(mpg1 mpg2= "Engine" mpg3 mpg4= "Size", labsize(5) angle(vert))
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	23.8 KB
ID:	1750614

      Comment

      Working...
      X