Announcement

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

  • stub_lag stub_lead in event_plot

    I try to run the five_estimators_stata.do of Kirill Borusyak available at https://github.com/ridwandse/Stata/b...ors_example.do
    I have installed all the necessary packages (and more)
    ssc install moremata, replace
    ssc install avar, replace
    ssc install did_imputation, replace
    ssc install did_multiplegt, replace
    ssc install reghdfe, replace
    ssc install event_plot, replace
    ssc install ftools, replace
    ssc install drdid, replace
    ssc install eventstudyinteract, replace
    github install lsun20/eventstudyinteract

    But when I run the script, after the event_plot of Chaisemartin and D'Haultfoeuille (2020), I have the following message:

    No estimates found. Make sure you have specified stub_lag and stub_lead correctly.

    I do not understand, everything is well specified:

    did_multiplegt Y i t D, robust_dynamic dynamic(5) placebo(5) breps(100) cluster(i)
    event_plot e(estimates)#e(variances), default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///
    title("de Chaisemartin and D'Haultfoeuille (2020)") xlabel(-5(1)5)) stub_lag(Effect_#) stub_lead(Placebo_#) together

    I work with STATA15, any help would be very much appreciated...

  • #2
    Ridwan Sheikh is a member here and may be able to comment.

    Comment


    • #3
      Thanks, Nick Cox for mentioning me here.

      Hi FABIEN CANDAU! Thank you for your interest. I am sorry for being a little late in the reply.
      The following line of codes should work


      Code:
      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)
      
      // Estimation with did_multiplegt of de Chaisemartin and D'Haultfoeuille (2020)
      
      did_multiplegt Y i t D, robust_dynamic dynamic(5) placebo(5) breps(100) cluster(i) 
      event_plot e(estimates)#e(variances), default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///
          title("de Chaisemartin and D'Haultfoeuille (2020)") xlabel(-5(1)5)) stub_lag(Effect_#) stub_lead(Placebo_#) together
      Run these codes without exiting the STATA
      The codes will produce the following event study plot based on de Chaisemartin and D'Haultfoeuille (2020)​​​​​​​ estimator


      Click image for larger version

Name:	dCdH.PNG
Views:	1
Size:	21.3 KB
ID:	1698772

      Comment

      Working...
      X