Dear Statalist member,
I run into an problem of tackling the following problem: I want to perform an event study in stata but my ID's have multiple event dates, so not only one event. How can I take care of this?
My goal is to create Cumulative Abnormal Returns, starting at t=-6(months) till t=24(months). The CAR has to be formed from every event (if possible) at every ID level.
My data is as following:
where event is equal to 0 --> the event is occurring
The following code I tried is at basic event study level, but does not counter the multiple events problem:
As you can imagine, this code does not work for multiple events.
Can somebody help me out here? Thansk in advance!
Best,
Arslan
I run into an problem of tackling the following problem: I want to perform an event study in stata but my ID's have multiple event dates, so not only one event. How can I take care of this?
My goal is to create Cumulative Abnormal Returns, starting at t=-6(months) till t=24(months). The CAR has to be formed from every event (if possible) at every ID level.
My data is as following:
where event is equal to 0 --> the event is occurring
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long date_stock float(ID ret event) 15736 1 . . 15764 1 -.1990291 . 15795 1 -.003787893 . 15825 1 .218251 . 15855 1 .13171028 . 15886 1 .07832323 0 15917 1 .11150897 . 15946 1 .11919007 . 15978 1 -.09087168 . 16009 1 .12709178 . 16037 1 .13483149 0 16070 1 .03394622 . 16100 1 .26060194 . 16128 1 -.072436295 . 16161 1 -.07487568 . 16191 1 -.14606383 . 16219 1 -.04850053 . 16252 1 .1392996 0 16282 1 -.18681698 . 16314 1 -.1390172 . 16344 1 .05219511 . 16373 1 .1617988 . 16405 1 -.08659218 . 16436 1 .05286156 . 19023 2 . . 19052 2 .0005063407 . 19082 2 .00708499 . 19113 2 .0080401935 0 19144 2 -.009471612 . 19173 2 .00654258 . 19205 2 .005500031 . 19236 2 -.0004972764 . 19264 2 .008457715 . 19297 2 0 . 19996 2 .8253576 0 20027 2 .17729734 0 20055 2 .3250689 . 20088 2 .07137905 . 20118 2 -.17464423 . 20146 2 .4102665 . 20178 2 -.15031958 . 20208 2 .13342053 0 20237 2 .12117717 . 20269 2 .120947 0 20300 2 -.12741053 0 20331 2 -.3788476 . 20361 2 -.05760273 0 20391 2 .04269666 . 20422 2 .05775863 . 20453 2 -.22330894 . 20482 2 -.062959015 0 20513 2 .14221719 . 20544 2 -.0299019 0 20573 2 .04042442 . 20605 2 .04468189 . 20635 2 .06090188 . 20664 2 -.006573165 0 20697 2 -.13718574 . 20727 2 -.1109407 . 20758 2 -.05750431 . 20788 2 -.4881025 . 20818 2 -.137068 0 20088 3 . . 20118 3 -.17464423 . 20146 3 .4102665 0 20178 3 -.15031958 . 20208 3 .13342053 0 20237 3 .12117717 . 20269 3 .120947 0 20300 3 -.12741053 . 20331 3 -.3788476 . 20361 3 -.05760273 . 20391 3 .04269666 . 20422 3 .05775863 . 20453 3 -.22330894 . 20482 3 -.062959015 0 20513 3 .14221719 . 20544 3 -.0299019 . 20573 3 .04042442 . 20605 3 .04468189 . 20635 3 .06090188 . 20664 3 -.006573165 . 20697 3 -.13718574 . 20727 3 -.1109407 . 20758 3 -.05750431 . 20788 3 -.4881025 . 20818 3 -.137068 0 19754 4 . . 19782 4 -.2311508 . 19813 4 .3866452 . 19843 4 -.08970364 0 19873 4 .00501914 . 19904 4 -.2645551 . 19935 4 -.1521865 . 19964 4 .2143649 . 19996 4 -.09325253 . 20027 4 -.20001186 . 20055 4 -.08333334 . 20088 4 -.37349495 . 20118 4 -.4840707 . 20146 4 .10656252 . 20178 4 .04563684 0 20208 4 .20996054 . 20237 4 -.23933037 . 20269 4 -.15317804 . 20300 4 -.08122522 . 20331 4 -.7096628 . 20361 4 -.3777605 . 20391 4 .02713986 . 20422 4 -.3105692 . 20453 4 .0117925 . 20482 4 -.09965035 . 20513 4 .10032364 . 20544 4 -.3058823 . 20573 4 .4194915 0 20605 4 .13910447 . 20635 4 -.23637317 . 20664 4 -.11736445 . 20697 4 .09875587 . 20727 4 .309271 0 20758 4 .845946 . 20788 4 -.1551977 . 20818 4 .8544194 0 19600 5 . . 19631 5 .0040160604 . 19662 5 .26800004 0 19691 5 .04022076 0 19723 5 .13798337 0 19754 5 -.09193871 . 19782 5 .7358767 . 19813 5 .04268809 . 19843 5 -.0879611 . 19873 5 -.04844445 . 19904 5 .08360583 . 19935 5 -.22413796 . 19964 5 .18 . 19996 5 -.2419962 0 20027 5 .00248441 . 20055 5 -.3277571 . 20088 5 .03410137 0 20118 5 -.2032086 . 20146 5 .3959732 0 20178 5 .11217954 . 20208 5 .028818415 . 20237 5 .25070035 0 20269 5 -.02799552 . 20300 5 .12039171 . 20331 5 .05964009 0 20361 5 -.08879184 . 20391 5 .09797657 . 20422 5 -.0906887 0 20453 5 -.0848 0 20482 5 -.04603724 . 20513 5 .09896144 . 20544 5 -.1712062 . 20573 5 -.2488263 . 20605 5 -.05803568 0 20635 5 .05687198 0 20664 5 .06188346 . 20697 5 .4231419 . 20727 5 .3181008 . 20758 5 -.13417378 0 20788 5 .28809157 . 20818 5 -.05369398 . 19600 6 . . 19631 6 .0040160604 . 19662 6 .26800004 0 19691 6 .04022076 . 19723 6 .13798337 0 19754 6 -.09193871 0 19782 6 .7358767 0 19813 6 .04268809 0 19843 6 -.0879611 . 19873 6 -.04844445 . 19904 6 .08360583 0 19935 6 -.22413796 . 19964 6 .18 0 19996 6 -.2419962 . 20027 6 .00248441 . 20055 6 -.3277571 . 20088 6 .03410137 . 20118 6 -.2032086 . 20146 6 .3959732 . 20178 6 .11217954 0 20208 6 .028818415 . 20237 6 .25070035 0 20269 6 -.02799552 . 20300 6 .12039171 . 20331 6 .05964009 . 20361 6 -.08879184 . 20391 6 .09797657 . 20422 6 -.0906887 . 20453 6 -.0848 0 20482 6 -.04603724 . 20513 6 .09896144 . 20544 6 -.1712062 . 20573 6 -.2488263 . 20605 6 -.05803568 . 20635 6 .05687198 0 20664 6 .06188346 . 20697 6 .4231419 0 20727 6 .3181008 . 20758 6 -.13417378 . 20788 6 .28809157 . 20818 6 -.05369398 . 19600 7 . . 19631 7 .0040160604 . 19662 7 .26800004 . 19691 7 .04022076 . 19723 7 .13798337 . 19754 7 -.09193871 0 19782 7 .7358767 . 19813 7 .04268809 . 19843 7 -.0879611 . 19873 7 -.04844445 . 19904 7 .08360583 0 19935 7 -.22413796 . 19964 7 .18 . 19996 7 -.2419962 . 20027 7 .00248441 . 20055 7 -.3277571 . 20088 7 .03410137 0 20118 7 -.2032086 . 20146 7 .3959732 . 20178 7 .11217954 0 20208 7 .028818415 . 20237 7 .25070035 . 20269 7 -.02799552 . 20300 7 .12039171 . 20331 7 .05964009 . 20361 7 -.08879184 . 20391 7 .09797657 0 20422 7 -.0906887 . 20453 7 -.0848 . 20482 7 -.04603724 . 20513 7 .09896144 . 20544 7 -.1712062 0 20573 7 -.2488263 . 20605 7 -.05803568 . 20635 7 .05687198 . 20664 7 .06188346 . 20697 7 .4231419 . 20727 7 .3181008 . 20758 7 -.13417378 . 20788 7 .28809157 . 20818 7 -.05369398 . 19600 8 . . 19631 8 .0040160604 . 19662 8 .26800004 . 19691 8 .04022076 . end format %d date_stock
Code:
sort ID date_stock // variable t will calibrate the events at t=0 and the months before till t=-6 and t=+24 which will be needed for the CAR later on. by ID: gen t=0 if event==0 //Filling in t for before and after t=0 by ID date_stock: replace t= t[_n-1]+1 if t==. gsort ID -date by ID: replace t= t[_n-1]-1 if t==. sort ID date //Deleting the dates I do not need (t<-6 and t>24) or ID's which do not have enough of data (e.g. t goes only down till t=-3 where we need at least t=-6) gen neg=. bys ID: replace neg=_N if t<0 gen negg=. bys ID neg: replace negg=_N if t<0 drop neg ren negg neg bys ID: replace neg=neg[_n-1] if neg==. drop if neg<6 drop if t<-6 drop if t>24 //Generating the NR & AR bysort ID (t): egen NR_MARM = mean(cond(t<0 & t>-6,ret,.)) gen AR_MARM = ret- NR_MARM
Can somebody help me out here? Thansk in advance!
Best,
Arslan
Comment