Since my last post didn't get any answers, im trying with the help of the FAQ to create a new post.
I am currently doing an eventstudy using STATA. My goal is to calculate abnormal returns around earningsannouncements for companies. I want to calculate abnormal returns as in the companies return during the eventwindow minus the return of a benchmark index. I then would like to use cumulative abnormal returns and t-test these returns to see if there is a drift in the returns after the announcements.
I am new to STATA. But i have followed the princeton guide on https://dss.princeton.edu/online_hel...ventstudy.html. I have cleaned my data and sorted the events according to daily return data over the companies. According to the guide, I've created duplicates of the datasets for each event that occurs. But i've gotten stuck on one part of the guide.
Code:
by group_id: gen event_window=1 if dif>=0& dif<=0 egen count_event_obs=count(event_window), by(group_id) by group_idstimation_window=1 if dif<- & dif>=-60 egen count_est_obs=count(estimation_window), by(company_id) replace event_window=0 if event_window==. replace estimation_window=0 if estimation_window==.
Also, i need to divide the companies events into "good" and "bad" depending on what earnings per share they got. I got a simple 1 if good and 0 if bad. How do i use this to divide the observations?
An example of my data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte company_id double return int date float(price set) double eps byte betterworse float(meaneps event_date group_id datenum td dif) 1 . 18228 125.26 1 .259 0 .28 18311 1 1 55 -54 1 -.0014380445076262846 18231 125.08 1 .259 0 .28 18311 1 2 55 -53 1 .009864837357746289 18232 126.32 1 .259 0 .28 18311 1 3 55 -52 1 -.0015052488482848712 18233 126.13 1 .259 0 .28 18311 1 4 55 -51 1 .006401412779222058 18234 126.94 1 .259 0 .28 18311 1 5 55 -50 1 -.007115216989250089 18235 126.04 1 .259 0 .28 18311 1 6 55 -49 1 -.002621649962334183 18238 125.71 1 .259 0 .28 18311 1 7 55 -48 1 -.001353234037353992 18239 125.54 1 .259 0 .28 18311 1 8 55 -47 1 -.010731263390007267 18240 124.2 1 .259 0 .28 18311 1 9 55 -46 1 -.0025798143943763347 18241 123.88 1 .259 0 .28 18311 1 10 55 -45 1 .010039841771961473 18242 125.13 1 .259 0 .28 18311 1 11 55 -44 1 .01175829865519824 18245 126.61 1 .259 0 .28 18311 1 12 55 -43 1 .006298737461127592 18246 127.41 1 .259 0 .28 18311 1 13 55 -42 1 .006181311493280127 18247 128.2 1 .259 0 .28 18311 1 14 55 -41 1 .00738297505527989 18248 129.15 1 .259 0 .28 18311 1 15 55 -40 1 .007713111898724894 18249 130.15 1 .259 0 .28 18311 1 16 55 -39 1 .004828890692555509 18252 130.78 1 .259 0 .28 18311 1 17 55 -38 1 .017734454939768694 18253 133.12 1 .259 0 .28 18311 1 18 55 -37 1 .010907840687273539 18254 134.58 1 .259 0 .28 18311 1 19 55 -36 1 .0020783855462640412 18259 134.86 1 .259 0 .28 18311 1 20 55 -35 1 .0013338275412109017 18260 135.04 1 .259 0 .28 18311 1 21 55 -34 1 -.008104434857029262 18261 133.95 1 .259 0 .28 18311 1 22 55 -33 1 .004543600234020249 18266 134.56 1 .259 0 .28 18311 1 23 55 -32 1 .0063708638328614535 18267 135.42 1 .259 0 .28 18311 1 24 55 -31 1 .021044178613213057 18269 138.3 1 .259 0 .28 18311 1 25 55 -30 1 .016493740705851787 18270 140.6 1 .259 0 .28 18311 1 26 55 -29 1 .009203604789432456 18273 141.9 1 .259 0 .28 18311 1 27 55 -28 1 -.01949823388225572 18274 139.16 1 .259 0 .28 18311 1 28 55 -27 1 -.010183902250717341 18275 137.75 1 .259 0 .28 18311 1 29 55 -26 1 .00658444548132053 18276 138.66 1 .259 0 .28 18311 1 30 55 -25 1 -.00093798484455662 18277 138.53 1 .259 0 .28 18311 1 31 55 -24 1 -.007826694058532877 18280 137.45 1 .259 0 .28 18311 1 32 55 -23 1 -.021027094365630553 18281 134.59 1 .259 0 .28 18311 1 33 55 -22 1 -.0035727615227753827 18282 134.11 1 .259 0 .28 18311 1 34 55 -21 1 -.014495728680542129 18283 132.18 1 .259 0 .28 18311 1 35 55 -20 1 -.013711366545913593 18284 130.38 1 .259 0 .28 18311 1 36 55 -19 1 .0037512005709960613 18287 130.87 1 .259 0 .28 18311 1 37 55 -18 1 .0013744657020262389 18288 131.05 1 .259 0 .28 18311 1 38 55 -17 1 .01649802820270519 18289 133.23 1 .259 0 .28 18311 1 39 55 -16 1 -.005796244915287079 18290 132.46 1 .259 0 .28 18311 1 40 55 -15 1 -.01268772955577249 18291 130.79 1 .259 0 .28 18311 1 41 55 -14 1 -.00367675634424631 18294 130.31 1 .259 0 .28 18311 1 42 55 -13 1 .014021413893483728 18295 132.15 1 .259 0 .28 18311 1 43 55 -12 1 .004002573028553517 18296 132.68 1 .259 0 .28 18311 1 44 55 -11 1 -.008629226205646826 18297 131.54 1 .259 0 .28 18311 1 45 55 -10 1 -.02353773767475341 18298 128.48 1 .259 0 .28 18311 1 46 55 -9 1 -.008912575609572138 18301 127.34 1 .259 0 .28 18311 1 47 55 -8 1 .004231649602761428 18302 127.88 1 .259 0 .28 18311 1 48 55 -7 1 -.008323565919755152 18303 126.82 1 .259 0 .28 18311 1 49 55 -6 1 .005269171878145423 18304 127.49 1 .259 0 .28 18311 1 50 55 -5 1 -.007637531712582929 18305 126.52 1 .259 0 .28 18311 1 51 55 -4 1 -.0021363302819788167 18308 126.25 1 .259 0 .28 18311 1 52 55 -3 1 .0015829049605049492 18309 126.45 1 .259 0 .28 18311 1 53 55 -2 1 .01577059871367229 18310 128.46 1 .259 0 .28 18311 1 54 55 -1 1 .05276348822785293 18311 135.42 1 .259 0 .28 18311 1 55 55 0 1 .026308677123952472 18312 139.03 1 .259 0 .28 18311 1 56 55 1 1 .008950688090525332 18315 140.28 1 .259 0 .28 18311 1 57 55 2 1 .0004988775359139897 18316 140.35 1 .259 0 .28 18311 1 58 55 3 1 -.008730554954106039 18317 139.13 1 .259 0 .28 18311 1 59 55 4 1 .0004311583855238409 18318 139.19 1 .259 0 .28 18311 1 60 55 5 1 .004515974844529871 18319 139.82 1 .259 0 .28 18311 1 61 55 6 1 .018424557470139654 18322 142.42 1 .259 0 .28 18311 1 62 55 7 1 -.030947211218860904 18394 138.08 1 .259 0 .28 18311 1 63 55 8 1 -.003191646405838158 18396 137.64 1 .259 0 .28 18311 1 64 55 9 1 -.031064585174950424 18399 133.43 1 .259 0 .28 18311 1 65 55 10 1 -.0011248173357967456 18400 133.28 1 .259 0 .28 18311 1 66 55 11 1 -.017712975405587236 18401 130.94 1 .259 0 .28 18311 1 67 55 12 1 -.021381695271212572 18402 128.17 1 .259 0 .28 18311 1 68 55 13 1 -.009958133021390782 18403 126.9 1 .259 0 .28 18311 1 69 55 14 1 .018658568546119785 18406 129.29 1 .259 0 .28 18311 1 70 55 15 1 -.02165754482901376 18407 126.52 1 .259 0 .28 18311 1 71 55 16 1 .012332743405596622 18408 128.09 1 .259 0 .28 18311 1 72 55 17 1 .022845787926370705 18409 131.05 1 .259 0 .28 18311 1 73 55 18 1 .008358711280882912 18410 132.15 1 .259 0 .28 18311 1 74 55 19 1 -.006376701179384567 18413 131.31 1 .259 0 .28 18311 1 75 55 20 1 -.010949992636268481 18414 129.88 1 .259 0 .28 18311 1 76 55 21 1 -.005713860036324097 18415 129.14 1 .259 0 .28 18311 1 77 55 22 1 .01886993169289578 18416 131.6 1 .259 0 .28 18311 1 78 55 23 1 .0006077180375428715 18417 131.68 1 .259 0 .28 18311 1 79 55 24 1 -.010228316024525426 18420 130.34 1 .259 0 .28 18311 1 80 55 25 1 .007947466560092464 18421 131.38 1 .259 0 .28 18311 1 81 55 26 1 .007356041208783431 18422 132.35 1 .259 0 .28 18311 1 82 55 27 1 .010522457103005693 18423 133.75 1 .259 0 .28 18311 1 83 55 28 1 .014031931481322146 18424 135.64 1 .259 0 .28 18311 1 84 55 29 1 .020215977651172567 18427 138.41 1 .259 0 .28 18311 1 85 55 30 1 .013847754915532163 18428 140.34 1 .259 0 .28 18311 1 86 55 31 1 -.002497058337408837 18429 139.99 1 .259 0 .28 18311 1 87 55 32 1 .005343225051669063 18430 140.74 1 .259 0 .28 18311 1 88 55 33 1 .001774749338866913 18431 140.99 1 .259 0 .28 18311 1 89 55 34 1 .019734479409676566 18434 143.8 1 .259 0 .28 18311 1 90 55 35 1 -.004530413742822283 18435 143.15 1 .259 0 .28 18311 1 91 55 36 1 -.009263874237607824 18436 141.83 1 .259 0 .28 18311 1 92 55 37 1 -.01979557662654233 18437 139.05 1 .259 0 .28 18311 1 93 55 38 1 -.0010793309196757944 18441 138.9 1 .259 0 .28 18311 1 94 55 39 1 -.02655539761350431 18442 135.26 1 .259 0 .28 18311 1 95 55 40 1 -.012348591044248514 18443 133.6 1 .259 0 .28 18311 1 96 55 41 1 -.005178053669303975 18444 132.91 1 .259 0 .28 18311 1 97 55 42 1 -.01837561195908576 18445 130.49 1 .259 0 .28 18311 1 98 55 43 1 -.0068438115559812645 18448 129.6 1 .259 0 .28 18311 1 99 55 44 1 .025670754950440213 18449 132.97 1 .259 0 .28 18311 1 100 55 45 end format %tdnn/dd/CCYY date format %tdnn/dd/YY event_date
Best regards
0 Response to Event study - sorting groups and assigning estimation windows
Post a Comment