Dear community,
I recently started exploring the fascinating package did_imputation by Borusyak et al. (2021) for a diff-in-diff imputation design (here is a reference). Now, I want to add a horizontal line to my event plot that only starts at the treatment time. Unfortunately, I haven't found a way to implement this, yet. I checked yline but this covers the whole range of the plot. I also checked addplot but this does not seem to be allowed when using the event_plot function. I also tried this option using pipes and scatteri but these commands also seem not to be allowed.
I come from R and I am quite unsure why there isn't an easy option to add a custom line/plot to an existing one. Can someone please help me?
I am using the example code by Borusyak et al. (2021):
This is what I get:

And this is what I want to have:

Thank you in advance!
I recently started exploring the fascinating package did_imputation by Borusyak et al. (2021) for a diff-in-diff imputation design (here is a reference). Now, I want to add a horizontal line to my event plot that only starts at the treatment time. Unfortunately, I haven't found a way to implement this, yet. I checked yline but this covers the whole range of the plot. I also checked addplot but this does not seem to be allowed when using the event_plot function. I also tried this option using pipes and scatteri but these commands also seem not to be allowed.
I come from R and I am quite unsure why there isn't an easy option to add a custom line/plot to an existing one. Can someone please help me?
I am using the example code by Borusyak et al. (2021):
Code:
// from https://github.com/borusyak/did_imputation/blob/main/five_estimators_example.do
clear all
timer clear
set seed 10
global T = 15
global I = 300
set obs `=$I*$T'
gen i = int((_n-1)/$T )+1 // unit id
gen t = mod((_n-1),$T )+1 // calendar period
tsset i t
// Randomly generate treatment rollout years uniformly across Ei=10..16 (note that periods t>=16 would not be useful since all units are treated by then)
gen Ei = ceil(runiform()*7)+$T -6 if t==1 // year when unit is first treated
bys i (t): replace Ei = Ei[1]
gen K = t-Ei // "relative time", i.e. the number periods since treated (could be missing if never-treated)
gen D = K>=0 & Ei!=. // treatment indicator
// Generate the outcome with parallel trends and heterogeneous treatment effects
gen tau = cond(D==1, (t-12.5), 0) // heterogeneous treatment effects (in this case vary over calendar periods)
gen eps = rnormal() // error term
gen Y = i + 3*t + tau*D + eps // the outcome (FEs play no role since all methods control for them)
//save five_estimators_data, replace
// Estimation with did_imputation of Borusyak et al. (2021)
did_imputation Y i t Ei,allhorizons pretrend(5) shift(1) autosample
ereturn list
event_plot, default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///
title("Borusyak et al. (2021) imputation estimator") xlabel(-5(1)5))
estimates store bjs // storing the estimates for later
And this is what I want to have:
Thank you in advance!

Comment