Announcement

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

  • Draw vertical line in coefplot

    Hi guys,

    I’m running regressions using the reghdfe command, and I want to plot the coefficients. 2007 is the intervention year. My codes are as below:
    reghdfe `X' i.treatment_adj##ib(2007).year, absorb( global_id year) vce(cluster global_id)

    coefplot, vertical drop(_cons) keep(1.treatment_adj*) yline(0) rename(^.*([0-9]+)([0-9]+)([0-9]+)([0-9]+).*$ = \1\2\3\4, regex) title("`X'_2000data_2007b_sample1_FE")

    In the coefficient plots, I want to include a vertical line of the intervention year (2007). I know the code for doing this is “xline”, but I had troubles in incorporating the xline code together with the coefficient plot code. When I add xline(2007), the vertical line is not drawn correctly in 2007 location

    coefplot, vertical drop(_cons) keep(1.treatment_adj*) yline(0) rename(^.*([0-9]+)([0-9]+)([0-9]+)([0-9]+).*$ = \1\2\3\4, regex) title("`X'_2000data_2007b_sample1_FE")

    Do you know how to fix it?

    Thank you in advance.
    Hut98

  • #2
    coefplot is from Stata Journal / SSC. You have yline(0) in your code, so xline() must work. You need to know your xaxis scale, and in the absence of a data example, it is difficult to advise.

    Comment


    • #3
      This is my code :

      reghdfe `X' i.treatment_adj##ib(2007).year, absorb( global_id year i.sec2##i.year) vce(cluster global_id)
      outreg2 using Output/Sascha_Sample1.xls, label ctitle("`X'") word addtext(Year FE, YES Industry FE, YES) keep (1.treatment_adj##i.year)
      coefplot, vertical drop(_cons) keep(1.treatment_adj*) yline(0) xline(2007) rename(^.*([0-9]+)([0-9]+)([0-9]+)([0-9]+).*$ = \1\2\3\4, regex) title("`X'_2000data_2007b_sample1_FE")

      Years are from 2003 --> 2014. And I don't know xasis scale. I also attach the coefplot graph.
      Attached Files

      Comment


      • #4
        Two points:

        1. Your xlabels show that 2007 is omitted as it is the base year. So to have it on the axis, include the option -baselevels- in the code.
        2. With the base year included, 2007 is xline(5), and if not included, 2006.5 is xline(4.5)

        Comment

        Working...
        X