Hello everyone,
I am running an event study on a panel data of US stocks, the events occur quarterly normally but are missing for some stocks and quarters. I am using the estimation window to predict the normal returns of an event-window. The data looks like this:
The problem is searching through all firm-quarters with or without an event. My life would become much more simple if I could replace the numeric values in the for loops with variables. is that possible to do? Any help is appreciated.
Hamid
I am running an event study on a panel data of US stocks, the events occur quarterly normally but are missing for some stocks and quarters. I am using the estimation window to predict the normal returns of an event-window. The data looks like this:
Code:
clear input float(permno date ret sp500 event permqtr TD event_window event_no est_window_90 ar_sd) 1 1 1 .5 0 1 1 0 0 1 2.3220067 1 2 -.5 .6 0 1 2 0 0 1 2.3220067 1 3 .5 .3 0 1 3 0 0 1 2.3220067 1 4 .6 .4 0 1 4 0 0 1 2.3220067 1 5 -.5 .5 0 1 5 0 0 1 2.3220067 1 6 -.6 .6 0 1 6 0 0 1 2.3220067 1 7 7 .3 1 1 7 1 1 0 2.3220067 1 8 6 .4 0 1 8 1 1 0 2.3220067 1 9 4 .5 0 1 9 1 1 0 2.3220067 1 10 8 .6 0 1 10 1 1 0 2.3220067 1 11 3 .3 0 1 11 1 1 0 2.3220067 1 12 .6 .4 0 1 12 0 1 . 2.3220067 1 13 -.5 .5 0 1 13 0 1 2 2.3220067 1 14 -.6 .6 0 1 14 0 1 2 2.3220067 1 15 .5 .3 0 1 15 0 1 2 2.3220067 1 16 1 .4 0 2 16 0 1 2 .6046011 1 17 -.5 .5 0 2 17 0 1 2 .6046011 1 18 .5 .6 0 2 18 0 1 2 .6046011 1 19 .6 .3 0 2 19 0 1 2 .6046011 1 20 -.5 .4 0 2 20 0 1 2 .6046011 end I am running the following code to predict the returns and it works alright.
Code:
gen firmno=group(permno) gen predict_ret=. forvalues i=1(1)10506 { forvalues j=1(1)37 { capture noisily reg ret sp500 if firmno==`i' & est_window_90==`j' if c(rc) == 0 { predict p if firmno==`i' replace predict_ret = p if event_window==1 & firmno==`i' & event_no==`j' drop p } } }
Hamid
Comment