Announcement

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

  • Coefplot: Define range for rconnected CI plots

    Hello,

    I am trying to plot the coefficients of a regression with multiple treated groups, differentiated by intensity of treatment (I use deciles of a continuous variable). I run a diff-in-diff regression with the 10 deciles (I omit the middle decile) and then the coefplot command to plot the coefficients. I also plot the 95% confidence interval in the same graph.

    I would like to include the omitted decile interaction in the coefplot. However, I don't want the confidence interval lines to connect to that point. That is, I would like the confidence interval lines (the black dashed lines in the image) to only appear between 1 and 4 and between 6 and 10, while the rconnected plot for the coefficients (the solid blue line) is defined for the entire interval. Is there a way to define the range in which the CI lines are visible? An example on what I am trying to achieve would be Figure 2 on page 167 in DeschĂȘnesand Greenstone (2011).

    Please see example code and graph below. Any help would be much appreciated!

    Best regards,
    Simon

    Code:
    sysuse nlsw88, clear
    * ssc install coefplot
    
    egen dexp = xtile(ttl_exp), nq(10) // Create deciles of experience
    
    reg wage ib5.dexp##i.collgrad
    
    #delimit;
    local lab 1/10;
    coefplot, drop(_cons 0.collgrad 1.collgrad *.dexp) levels(95)
    vertical yline(0) recast(connected) ciopts(recast(rconnected) lpattern(dash) color(black))
    legend(order(2 "Coefficient" 1 "95% CI") row(1)) xlabel(`lab')
    xtitle("Experience Decile Interacted with College Degree") title("Wage")
    xsize(4.6) baselevels
    ;
    #delimit cr
    Click image for larger version

Name:	coefplot.png
Views:	1
Size:	70.6 KB
ID:	1549892


  • #2
    use the generate() option with -coefplot- (by Ben Jann, -ssc desc coefplot-) and reconstruct the graph:

    Code:
    ...
    xsize(4.6) baselevels generate(coef) 
    ;
    #delimit cr
    
    
    twoway connected coefb coefat, lc(blue)  /// 
     || connected coeful1 coefat if coefat <=4 , lp(dash) lc(black) mc(black) ///
     || connected coeful1 coefat if coefat >5 , lp(dash)   lc(black) mc(black) ///
     || connected coefll1 coefat if coefat <=4 , lp(dash)  lc(black) mc(black)  ///
     || connected coefll1 coefat if coefat >5 , lp(dash)  lc(black) mc(black) /// 
     ||,  legend(order(1 "Coefficient" 2 "95% CI")) /// 
      xtitle("Experience Decile Interacted with College Degree") title("Wage")

    Comment


    • #3
      Originally posted by Scott Merryman View Post
      use the generate() option with -coefplot- (by Ben Jann, -ssc desc coefplot-) and reconstruct the graph:

      Code:
      ...
      xsize(4.6) baselevels generate(coef)
      ;
      #delimit cr
      
      
      twoway connected coefb coefat, lc(blue) ///
      || connected coeful1 coefat if coefat <=4 , lp(dash) lc(black) mc(black) ///
      || connected coeful1 coefat if coefat >5 , lp(dash) lc(black) mc(black) ///
      || connected coefll1 coefat if coefat <=4 , lp(dash) lc(black) mc(black) ///
      || connected coefll1 coefat if coefat >5 , lp(dash) lc(black) mc(black) ///
      ||, legend(order(1 "Coefficient" 2 "95% CI")) ///
      xtitle("Experience Decile Interacted with College Degree") title("Wage")
      Thank you, Scott! That worked perfectly.

      Comment

      Working...
      X