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
Calculate weight for repeated cross-sectional data collected weekly since May 2020Hi Could you please suggest how do I calculate weight for the data considered as repeated cross-sect…
Query of small sampleDear Statalist, I would like to get your advice about a stata command. I prefer to generate a small …
How to compare two data which contain different time frequencies?Hi, I am trying to compare two datasets such as Bitcoin and AAPL. As you realized that Bitcoin data …
Unable to access Stata MP2 on UbuntuI have been using Stata on windows 10 for sometime now and recently got a laptop with Ubuntu 20.04 i…
Replicate R's pnorm functionHi Statalist, I'm porting a couple R scripts to Stata and have hit a roadblock. I have been unable …
Subscribe to:
Post Comments (Atom)
0 Response to Using loops to generate dummy for placebo regressions
Post a Comment