Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72776

Simulation exercise in difference-in-difference set up

$
0
0
Hi everybody,

I am currently trying to set up a simulation exercise in Stata SE 14.0 and could use some input. In particular, I have a panel data set with firms and years and would like to solidify my findings from a difference-in-difference estimation by running a simulation, which randomly assigns firm-years to the "treated" (1) or "untreated" (0) groups.

The basic equation to be estimated is yit = aj + ab + ay + b treat * inti,t-1 + eit. I want to replace the real data for "treat" (1/0) with simulated values and re-run the original estimation 1000 times.

I am using the user-written command reghdfe (available from SSC, highly recommended) to deal with a faster estimation of regressions with multiple fixed effects. (Note that this is largely irrelevant for my question.)

The code I am running looks like this:

Code:
set seed 12345
postfile simul beta using simulation, replace

forvalues i = 1/1000 {
  gen order=runiform()
  sort order
  gen plac=0 if treat!=.
  replace plac=1 if _n<=3590 & treat!=.
  drop order
  sort gvkey year
 
  gen ltreat_int=l.treat*int
  reghdfe y ltreat_int, a(year industry bank) cluster(gvkey)
  loc beta=_b[ltreat_int]
  post simul (`beta')
  drop ltreat_int
 
  drop plac
}

postclose simul
use simulation, clear
summarize
I have not worked with simulations before but this estimation will take days even on the fastest PC I have at my disposal. Is there any more efficient way to set this up?

Cheers,
Karsten

Viewing all articles
Browse latest Browse all 72776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>