Announcement

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

  • Add reference time point onto coefplot x axis

    I'm using coefplot (a community-written command from the Stata Journal) after running the below model. The reference time point is t-1 (where t=0 is the month that an individual was arrested), and therefore it does not have an associated coefficient and does not show by default in the graph.

    In the graph, I have relabeled time points such that, eg, "3" is 3 months following the reference time period, and added a red line to denote the reference period. My question is if there is some way to replace the vertical line with a new x axis point where the reference time period would be? I presume that x axis spot would remain blank (or perhaps have a point at y=0).

    My data are in a restricted environment, but I show an example code snippet analogous to my own and an image of the graph it produces.
    Code:
    reghdfe outcome (arrest_pre7-arrest_post11), absorb (id month)
    
    coefplot, vertical keep(arrest*) yline(0) xlabel(, angle(45)) ///
    coeflabels(arrest_pre7="-6" arrest_pre6="-5" [...and so on])


    Click image for larger version

Name:	example.png
Views:	1
Size:	28.6 KB
ID:	1775244


  • #2
    It would be easier if you created a categorical variable for the time periods. Then, you could use factor variable notation, and coefplot would keep track of the base level. Otherwise, you would need to trick the estimation command into including an omitted coefficient, which you can specify as an artificial base (see, e.g., https://www.statalist.org/forums/for...-with-coefplot).

    Code:
    webuse sp500, clear
    gen ym= ym(year(date), month(date))
    regress volume ib497.ym
    coefplot, vert baselevels xlab(1 "{it:t-5}" 2 "{it:t-4}" 5 "{it:t-1}" ///
    6 "{it:start}" 7 "{it:t+1}" 12 "{it:t+6}" 13 "{it:t+7}")
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	28.6 KB
ID:	1775249

    Comment


    • #3
      Thanks Andrew!

      Comment

      Working...
      X