Announcement

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

  • Problem writting vertical line in coefpolt command

    I am trying to do a coefplot, with all my regressions coefficient, This is the command I am using:


    Code:
    reghdfe lfatalities0_UCDP ///
        Treat_lag5 Treat_lag4 Treat_lag3 Treat_lag2 Treat_lag1 ///
        Treat_0 ///
        TREAT_lead1 TREAT_lead2 TREAT_lead3 TREAT_lead4 TREAT_lead5 ///
        TREAT_lag5_LD TREAT_lag4_LD TREAT_lag3_LD TREAT_lag2_LD TREAT_lag1_LD///
        TREAT_0_LD ///
        TREAT_lead1_LD TREAT_lead2_LD TREAT_lead3_LD TREAT_lead4_LD TREAT_lead5_LD ///
        raindev tempdev, absorb(i.ccode#i.year) cluster(UID)
    
    coefplot ///
        (., keep(TREAT_lag5 TREAT_lag4 TREAT_lag3 TREAT_lag2 TREAT_lag1 ///
                 TREAT_0 TREAT_lead1 TREAT_lead2 TREAT_lead3 TREAT_lead4 TREAT_lead5) ///
             label("Main Effect") ///
             rename(TREAT_lag5 = "-5" TREAT_lag4 = "-4" TREAT_lag3 = "-3" TREAT_lag2 = "-2" TREAT_lag2 = "-1" ///
                    TREAT_0 = "0" TREAT_lead1 = "+1" TREAT_lead2 = "+2" TREAT_lead3 = "+3" TREAT_lead4 = "+4" TREAT_lead5 = "+5") ///
             mcolor(blue) msymbol(circle) lcolor(blue)) ///
        (., keep(TREAT_lag5_LD TREAT_lag4_LD TREAT_lag3_LD TREAT_lag2_LD TREAT_lag1_LD ///
                 TREAT_0_LD TREAT_lead1_LD TREAT_lead2_LD TREAT_lead3_LD TREAT_lead4_LD TREAT_lead5_LD) ///
             label("Interaction") ///
             rename(TREAT_lag5_LD = "-5" TREAT_lag4_LD = "-4" TREAT_lag3_LD = "-3" TREAT_lag2_LD = "-2" TREAT_lag2_LD = "-1" ///
                    TREAT_0_LD = "0" TREAT_lead1_LD = "+1" TREAT_lead2_LD = "+2" TREAT_lead3_LD = "+3" TREAT_lead4_LD = "+4" TREAT_lead5_LD = "+5") ///
             mcolor(red) msymbol(circle) lcolor(red)) ///
        , vertical drop(_cons) ///
        xline(0, lpattern(dash)) ///
        yline(0, lcolor(gs10)) ///
        title("Dynamic Effects")

    With that code, I am obtaining a vertical line outside of the graph, when I would like to have in 0. This is the graph:
    Click image for larger version

Name:	CoefplotCheck.png
Views:	1
Size:	35.6 KB
ID:	1777973




    Any advice?
    Last edited by Diego Malo; 26 May 2025, 07:36.

  • #2
    "-5" is at position 1, so "0" is at position 5 on the x-axis. Note that coefplot is from SSC, as you are asked to explain (FAQ Advice #12).

    Code:
    xline(5, lpattern(dash)) ///

    Comment


    • #3
      What happened to -1 noting that the sequence of labels runs -5/-2 0/5?

      Comment


      • #4
        It works Andrew Musau . Thank you so much!

        Nick Cox Good catch! It is because I updated the graph without lag1, to maintain a referencee group. However, the problem was the same, including or removing lag1. Andrew's solution works!

        Comment

        Working...
        X