Announcement

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

  • How to draw two base lines using coefplot command on stata.

    Hi,

    I'm trying to look at the average effect in the pre- and post treatment time periods. For that I wish to plot 2 base lines (average of coefficients obtained), one for the pre-treatent time periods and other for the post treatment time periods using the coefplot command on stata. Could someone help me understand how do I get two baselines in the same graph using xline condition or something of that sort?

  • #2
    I am not too familiar with -coefplot-, but you can have multiple values in the -xline()- option

    Code:
    sysuse auto
    regress price mpg
    coefplot, xline(-225 -275) drop(_cons)

    Comment


    • #3
      Thank you for replying Scott. But I did not correctly write my query. I want to create two horizontal reference lines similar to the picture attached with this post. The reference lines cut in between. If you've any idea then please help.
      Attached Files

      Comment


      • #4
        There might be a way to doing this in -coefplot- but here in another way using Roger Newson's -parmby- to collect the estimation results (-ssc desc parmest- for the various modules make up the parmest package).

        Code:
        webuse grunfeld,clear
        qui parmby "reg invest mvalue" ,by(year) fast
        
        twoway connect est year if parm == "mvalue" , mc(black) lp(dash)  /// 
        || rcap max min year if parm == "mvalue", lc(gs10) /// 
        || scatteri .09 1935 .09 1945, recast(line) lw(thick) lp(dash)  lc(gs6) /// 
        || scatteri .19 1946 .19 1955 , recast(line) lw(thick) lp(dash) lc(gs6) /// 
        || , legend(off) xline(1945.5, lp(solid) lw(medthick) lc(black))
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	32.4 KB
ID:	1505130

        Comment


        • #5
          Thank you so much for your response. I have managed to create the reference lines.
          However, I'm unable to plot the coefficients. Attached with this post a picture of name of all the coefficients by year.
          Attached Files

          Comment


          • #6
            This is the command I've used:

            qui parmby "reghdfe work 1.treat#ib(1999).year zero if rural==1 & sex==0 & age>14 & age<60, absorb(district year age_cat)vce(cluster district)", by(year) fast

            Comment


            • #7
              You might want to think about your specification. You have year dummy variables interacted with treatment variable, year fixed effects, and you are going each regression by year.

              Comment

              Working...
              X