Dear Statalist,
I'm running an event study on the princeton method (http://dss.princeton.edu/online_help...ventstudy.html). I've successfully merged my data for the FTSE350, with 72 events over ~29 years, and i am now trying to organise and clean the data but have run into trouble.
My steps:
2. Now i try to create a variable that ensures there are the minimum number of observations after
the eventdate as well as the min number of obs before the event window for the estimation window.
However at this stage none of the observations are dropped since the values for 'count_event_obs, count_est_obs' are always 7239 (which is the same as the maximum of 'datenum'). So when i later try to regress the model with loops it just gives the 'no observations' r2000 error message (because there is no return ['ret'] for the first company on that date). All the data is in numeric form.
How do i code the above to recognise this properly?
Below is a sample from company 1 (where there is no data for return) for the first event.
Thank you
I'm running an event study on the princeton method (http://dss.princeton.edu/online_help...ventstudy.html). I've successfully merged my data for the FTSE350, with 72 events over ~29 years, and i am now trying to organise and clean the data but have run into trouble.
My steps:
- i calculated 'dif' which counts the days to each event (based on trading days) - this worked fine.
Code:
sort group_id date by group_id: gen datenum=_n by group_id: gen target=datenum if date==event_date egen td=min(target), by(group_id) drop target gen dif=datenum-td
the eventdate as well as the min number of obs before the event window for the estimation window.
Code:
by group_id: gen event_window=1 if dif>=1 & dif<=20 egen count_event_obs=count(event_window), by(group_id) by group_id: gen estimation_window=1 if dif<-10 & dif>=-136 egen count_est_obs=count(estimation_window), by(group_id) replace event_window=0 if event_window==. replace estimation_window=0 if estimation_window==. drop if count_event_obs < 20 drop if count_est_obs < 126
However at this stage none of the observations are dropped since the values for 'count_event_obs, count_est_obs' are always 7239 (which is the same as the maximum of 'datenum'). So when i later try to regress the model with loops it just gives the 'no observations' r2000 error message (because there is no return ['ret'] for the first company on that date). All the data is in numeric form.
How do i code the above to recognise this properly?
Below is a sample from company 1 (where there is no data for return) for the first event.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(company_id ret) float(rmrf smb hml) str9 date byte set str9 event_date byte group_id int(datenum td) byte(dif event_window estimation_window predicted_return id) int(count_event_obs count_est_obs target) 1 . -.00042 -.003461 -.000548 "29-Sep-89" 1 "16-Oct-89" 1 260 271 -11 0 1 . 1 7239 7239 . 1 . -.0005 .000021 .000906 "02-Oct-89" 1 "16-Oct-89" 1 261 271 -10 0 0 . 1 7239 7239 . 1 . -.00031 -.005591 -.002691 "03-Oct-89" 1 "16-Oct-89" 1 262 271 -9 0 0 . 1 7239 7239 . 1 . -.00032 -.007059 -.000465 "04-Oct-89" 1 "16-Oct-89" 1 263 271 -8 0 0 . 1 7239 7239 . 1 . -.00042 -.01392 .005066 "05-Oct-89" 1 "16-Oct-89" 1 264 271 -7 0 0 . 1 7239 7239 . 1 . .00051 .005306 -.007944 "06-Oct-89" 1 "16-Oct-89" 1 265 271 -6 0 0 . 1 7239 7239 . 1 . -.00006 -.000687 -.002605 "09-Oct-89" 1 "16-Oct-89" 1 266 271 -5 0 0 . 1 7239 7239 . 1 . -.00044 .003091 .000139 "10-Oct-89" 1 "16-Oct-89" 1 267 271 -4 0 0 . 1 7239 7239 . 1 . -.00015 -.000951 .004418 "11-Oct-89" 1 "16-Oct-89" 1 268 271 -3 0 0 . 1 7239 7239 . 1 . -.00053 .014565 -.003523 "12-Oct-89" 1 "16-Oct-89" 1 269 271 -2 0 0 . 1 7239 7239 . 1 . -.00006 .006328 .002321 "13-Oct-89" 1 "16-Oct-89" 1 270 271 -1 0 0 . 1 7239 7239 . 1 . .00041 .006482 -.005457 "16-Oct-89" 1 "16-Oct-89" 1 271 271 0 0 0 . 1 7239 7239 271 1 . .00032 .003703 -.002295 "17-Oct-89" 1 "16-Oct-89" 1 272 271 1 1 0 . 1 7239 7239 . 1 . -.00025 -.001736 .003873 "18-Oct-89" 1 "16-Oct-89" 1 273 271 2 1 0 . 1 7239 7239 . end
Thank you
Comment