Hi
In my dataset I have yearly variable, from 1995 to 2006 and a treatment happening in year 2003. I want to estimate the placebo effect ( that requires a me to generate random fake dummies) then estimate the estimate the difference in difference (DID regression) using all of the randomly generated placebo dummies and I need to store the DID coefficients and take the average of their effect. So in a first step I need to use loop to generate dummies. So I would need my loop outcome total number of dummies that is equal to 14 years (total number of years -2= 16-2). Therefore the first dummy would take on the value of 1 from 2000 and onwards, the second dummy will take the value of 1 in 2001 and zero otherwise, the third dummy would take on the value of 1 in 2002 and zero otherwise... etc. In or to generate this, I used the following loop code
[/
levels of x, local(year) foreach lev of local year {
gen x_`lev'=0 replace x_`lev'=1 if year>x("`lev'") } ]
When I run this loop, I do not get any output in my dataset. Any idea what is wrong in my code ? Many thanks
Related Posts with Using loops to generate dummy for placebo regressions
Creat Opposite VariableHello I generated a variable to identify zombie firms with this coomand "gen Zombie = (l2.icr <1…
Estimates Restore with Lasso - "no observations" errorHi everyone, I am trying to to in-sample and out of sample prediction with lasso. The following step…
LR test mixed results, any advice on what to do?Hello everyone, I am very new here and a very new user of Stata. I am currently in my final year in…
Two new programs, -rqrs- and -which_version-, available from SSCThanks, as always to Kit Baum, two new programs, rqrs and which_version, are available for download …
Cell sample size in multilevel ordered logit modelsDear all, I am writing to ask whether there is any rule of thumb on the minimum cell size (N) for ru…
Subscribe to:
Post Comments (Atom)
0 Response to Using loops to generate dummy for placebo regressions
Post a Comment