Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Event Study, creating event windows

    Dear Sir/Madam,

    I have a question regarding the creation of event windows. As shown below I have a stata file with dates and the stock returns index of the S&P merged with the dates when a terrorist attack happened. This leads to multiple events, however I cannot seen to get the event windows in my file. I have tried the following;

    sort date
    by date: gen datenum=_n
    by date: gen target=datenum if date==event_date
    egen td=min(target), by(company_id)
    drop target
    gen dif=datenum-td

    by date: gen event_window=1 if dif>=-2 & dif<=2

    However, this does not create event windows, possibly due to the fact that I use an index instead of multiple "companies"?
    I am trying to create event windows of [-2,2], [-5,5] and [-10,10], but I am struggeling.

    I am hoping that you can help me.

    Thank you in advance

    With kind regards,
    Heger Maathuis


    [CODE]
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int date double Returnmarket float(month year day) str8 year_month_day int Event_Date
    11962     .00996204933586325 10 1992  1 "1992101"      .
    11973  -.0013068789354876967 10 1992 12 "19921012"     .
    11974   .0015465143944800792 10 1992 13 "19921013"     .
    11975    .005463831809003539 10 1992 14 "19921014"     .
    11976   -.004370939161252268 10 1992 15 "19921015"     .
    11977   -.013407688656858038 10 1992 16 "19921016"     .
    11980    .005892964521948224 10 1992 19 "19921019"     .
    11963    .015382808830436853 10 1992  2 "1992102"      .
    11981  .00023912003825915854 10 1992 20 "19921020"     .
    11982  -.0033468802295003723 10 1992 21 "19921021"     .
    11983   .0046773806668265845 10 1992 22 "19921022"     .
    11984   -.005491225975886281 10 1992 23 "19921023"     .
    11987  -.0022806385788020373 10 1992 26 "19921026"     .
    11988   .0037295476419634535 10 1992 27 "19921027"     .
    11989  -.0008390267289944551 10 1992 28 "19921028"     .
    11990  -.0013195777351247533 10 1992 29 "19921029"     .
    11991   .0031231231231231846 10 1992 30 "19921030"     .
    11966     .00439458771828391 10 1992  5 "1992105"      .
    11967  .00046056419113404767 10 1992  6 "1992106"      .
    11968   -.010818275981125535 10 1992  7 "1992107"      .
    11969   -.010122164048865671 10 1992  8 "1992108"      .
    11970    -.01069581570286785 10 1992  9 "1992109"      .
    11697   -.007575757575757606  1 1992 10 "1992110"      .
    12002   .0028305224672720234 11 1992 10 "19921110"     .
    12003   -.010349288486416506 11 1992 11 "19921111" 12003
    12004   -.009269162210338694 11 1992 12 "19921112"     .
    12005  -.0015593139018832871 11 1992 13 "19921113"     .
    12008   .0012013455069679064 11 1992 16 "19921116"     .
    12009   -.006599472042236587 11 1992 17 "19921117"     .
    12010    .001449450416716878 11 1992 18 "19921118"     .
    12011    .009769629718972408 11 1992 19 "19921119" 12011
    11994     .00850197581128001 11 1992  2 "1992112"  11994
    12012    .006211180124223555 11 1992 20 "19921120"     .
    12015    .006410256410256485 11 1992 23 "19921123"     .
    12016    .003656522764803046 11 1992 24 "19921124"     .
    12017                      0 11 1992 25 "19921125"     .
    12018    .009871900340815646 11 1992 26 "19921126"     .
    12019     .01477947166298145 11 1992 27 "19921127"     .
    11700   .0009814612868048354  1 1992 13 "1992113"      .
    12022    .003096330275229312 11 1992 30 "19921130"     .
    11701  -.0015252206122671377  1 1992 14 "1992114"      .
    11702  .00032733224222587163  1 1992 15 "1992115"      .
    11703    -.00828970331588138  1 1992 16 "1992116"      .
    11704    -.01396832380114382  1 1992 17 "1992117"      .
    12001    .001417267036730891 11 1992  9 "1992119"      .
    11689    .010210732131218746  1 1992  2 "199212"       .
    11707    .002007808142777385  1 1992 20 "1992120"      .
    12023    .011546816051217618 12 1992  1 "1992121"  12023
    12032    .003781138790035625 12 1992 10 "19921210" 12032
    12033   -.005096388211832572 12 1992 11 "19921211" 12033
    12036  -.0015590200445434362 12 1992 14 "19921214"     .
    12037   .0006691947356681048 12 1992 15 "19921215"     .
    12038    .003566651805617559 12 1992 16 "19921216"     .
    12039   .0019991115059972524 12 1992 17 "19921217"     .
    12040   -.003103524717357583 12 1992 18 "19921218"     .
    12024    .004746835443037994 12 1992  2 "1992122"      .
    12043    .001111852346008545 12 1992 21 "19921221"     .
    12044   .0006663705019991367 12 1992 22 "19921222"     .
    12045    .005660377358490464 12 1992 23 "19921223"     .
    12046                      0 12 1992 24 "19921224" 12046
    12047    .005297428539896303 12 1992 25 "19921225"     .
    12050    .010868371939839663 12 1992 28 "19921228"     .
    12051    .002063423110338811 12 1992 29 "19921229"     .
    12025    .006299212598425222 12 1992  3 "1992123"      .
    12052  -.0013005310501787183 12 1992 30 "19921230"     .
    --more--

  • #2
    Presumably, if you have multiple events, you will need a window for each event. The following example uses rangejoin (from SSC) to match each event to observations from your data example that are within -5/+5 calendar days from the event date. If you want windows based on business days, you will have to use business calendars. The problem with that is that you cannot represent an event that happens on a weekend or holiday with a business calendar. An option then is to use calendar dates and overshoot on the window. You can always drop observations to reduce each event by-group to the desired number of business days before and after the event.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int date double Returnmarket int Event_Date
    11962    .00996204933586325     .
    11973 -.0013068789354876967     .
    11974  .0015465143944800792     .
    11975   .005463831809003539     .
    11976  -.004370939161252268     .
    11977  -.013407688656858038     .
    11980   .005892964521948224     .
    11963   .015382808830436853     .
    11981 .00023912003825915854     .
    11982 -.0033468802295003723     .
    11983  .0046773806668265845     .
    11984  -.005491225975886281     .
    11987 -.0022806385788020373     .
    11988  .0037295476419634535     .
    11989 -.0008390267289944551     .
    11990 -.0013195777351247533     .
    11991  .0031231231231231846     .
    11966    .00439458771828391     .
    11967 .00046056419113404767     .
    11968  -.010818275981125535     .
    11969  -.010122164048865671     .
    11970   -.01069581570286785     .
    11697  -.007575757575757606     .
    12002  .0028305224672720234     .
    12003  -.010349288486416506 12003
    12004  -.009269162210338694     .
    12005 -.0015593139018832871     .
    12008  .0012013455069679064     .
    12009  -.006599472042236587     .
    12010   .001449450416716878     .
    12011   .009769629718972408 12011
    11994    .00850197581128001 11994
    12012   .006211180124223555     .
    12015   .006410256410256485     .
    12016   .003656522764803046     .
    12017                     0     .
    12018   .009871900340815646     .
    12019    .01477947166298145     .
    11700  .0009814612868048354     .
    12022   .003096330275229312     .
    11701 -.0015252206122671377     .
    11702 .00032733224222587163     .
    11703   -.00828970331588138     .
    11704   -.01396832380114382     .
    12001   .001417267036730891     .
    11689   .010210732131218746     .
    11707   .002007808142777385     .
    12023   .011546816051217618 12023
    12032   .003781138790035625 12032
    12033  -.005096388211832572 12033
    12036 -.0015590200445434362     .
    12037  .0006691947356681048     .
    12038   .003566651805617559     .
    12039  .0019991115059972524     .
    12040  -.003103524717357583     .
    12024   .004746835443037994     .
    12043   .001111852346008545     .
    12044  .0006663705019991367     .
    12045   .005660377358490464     .
    12046                     0 12046
    12047   .005297428539896303     .
    12050   .010868371939839663     .
    12051   .002063423110338811     .
    12025   .006299212598425222     .
    12052 -.0013005310501787183     .
    end
    format %td date Event_Date
    save "dataex.dta", replace
    
    keep Event_Date
    keep if !mi(Event_Date)
    gen low = Event_Date - 5
    gen high = Event_Date + 5
    rangejoin date low high using "dataex.dta"
    list , sepby(Event_Date)
    and the results:
    Code:
    . list , sepby(Event_Date)
    
         +----------------------------------------------------------------+
         | Event_D~e     low    high        date   Returnma~t   Event_D~U |
         |----------------------------------------------------------------|
      1. | 11nov1992   11998   12008   09nov1992    .00141727           . |
      2. | 11nov1992   11998   12008   10nov1992    .00283052           . |
      3. | 11nov1992   11998   12008   11nov1992   -.01034929   11nov1992 |
      4. | 11nov1992   11998   12008   12nov1992   -.00926916           . |
      5. | 11nov1992   11998   12008   13nov1992   -.00155931           . |
      6. | 11nov1992   11998   12008   16nov1992    .00120135           . |
         |----------------------------------------------------------------|
      7. | 19nov1992   12006   12016   16nov1992    .00120135           . |
      8. | 19nov1992   12006   12016   17nov1992   -.00659947           . |
      9. | 19nov1992   12006   12016   18nov1992    .00144945           . |
     10. | 19nov1992   12006   12016   19nov1992    .00976963   19nov1992 |
     11. | 19nov1992   12006   12016   20nov1992    .00621118           . |
     12. | 19nov1992   12006   12016   23nov1992    .00641026           . |
     13. | 19nov1992   12006   12016   24nov1992    .00365652           . |
         |----------------------------------------------------------------|
     14. | 02nov1992   11989   11999   28oct1992   -.00083903           . |
     15. | 02nov1992   11989   11999   29oct1992   -.00131958           . |
     16. | 02nov1992   11989   11999   30oct1992    .00312312           . |
     17. | 02nov1992   11989   11999   02nov1992    .00850198   02nov1992 |
         |----------------------------------------------------------------|
     18. | 01dec1992   12018   12028   26nov1992     .0098719           . |
     19. | 01dec1992   12018   12028   27nov1992    .01477947           . |
     20. | 01dec1992   12018   12028   30nov1992    .00309633           . |
     21. | 01dec1992   12018   12028   01dec1992    .01154682   01dec1992 |
     22. | 01dec1992   12018   12028   02dec1992    .00474684           . |
     23. | 01dec1992   12018   12028   03dec1992    .00629921           . |
         |----------------------------------------------------------------|
     24. | 10dec1992   12027   12037   10dec1992    .00378114   10dec1992 |
     25. | 10dec1992   12027   12037   11dec1992   -.00509639   11dec1992 |
     26. | 10dec1992   12027   12037   14dec1992   -.00155902           . |
     27. | 10dec1992   12027   12037   15dec1992    .00066919           . |
         |----------------------------------------------------------------|
     28. | 11dec1992   12028   12038   10dec1992    .00378114   10dec1992 |
     29. | 11dec1992   12028   12038   11dec1992   -.00509639   11dec1992 |
     30. | 11dec1992   12028   12038   14dec1992   -.00155902           . |
     31. | 11dec1992   12028   12038   15dec1992    .00066919           . |
     32. | 11dec1992   12028   12038   16dec1992    .00356665           . |
         |----------------------------------------------------------------|
     33. | 24dec1992   12041   12051   21dec1992    .00111185           . |
     34. | 24dec1992   12041   12051   22dec1992    .00066637           . |
     35. | 24dec1992   12041   12051   23dec1992    .00566038           . |
     36. | 24dec1992   12041   12051   24dec1992            0   24dec1992 |
     37. | 24dec1992   12041   12051   25dec1992    .00529743           . |
     38. | 24dec1992   12041   12051   28dec1992    .01086837           . |
     39. | 24dec1992   12041   12051   29dec1992    .00206342           . |
         +----------------------------------------------------------------+

    Comment


    • #3
      Dear Robert,

      I followed your instructions above and got the same result, as shown down below. What I don't really get about what we did, is that we did not create actual windows that I can use for the event study. From what I know, event windows are formatted as (-2,-1,0,1,2). I don't understand how I should regress the market return on the event window, since there is no "0" in there. Could you help me understand how I should perform a regression for the event window in these data?

      With kind regards,
      Heger Maathuis

      [CODE]
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int Event_Date float(low high) int date double Returnmarket float(month year day) str8 year_month_day int Event_Date_U
      12003 11998 12008 12001   .001417267036730891 11 1992  9 "1992119"      .
      12003 11998 12008 12002  .0028305224672720234 11 1992 10 "19921110"     .
      12003 11998 12008 12003  -.010349288486416506 11 1992 11 "19921111" 12003
      12003 11998 12008 12004  -.009269162210338694 11 1992 12 "19921112"     .
      12003 11998 12008 12005 -.0015593139018832871 11 1992 13 "19921113"     .
      12003 11998 12008 12008  .0012013455069679064 11 1992 16 "19921116"     .
      12011 12006 12016 12008  .0012013455069679064 11 1992 16 "19921116"     .
      12011 12006 12016 12009  -.006599472042236587 11 1992 17 "19921117"     .
      12011 12006 12016 12010   .001449450416716878 11 1992 18 "19921118"     .
      12011 12006 12016 12011   .009769629718972408 11 1992 19 "19921119" 12011
      12011 12006 12016 12012   .006211180124223555 11 1992 20 "19921120"     .
      12011 12006 12016 12015   .006410256410256485 11 1992 23 "19921123"     .
      12011 12006 12016 12016   .003656522764803046 11 1992 24 "19921124"     .
      11994 11989 11999 11989 -.0008390267289944551 10 1992 28 "19921028"     .
      11994 11989 11999 11990 -.0013195777351247533 10 1992 29 "19921029"     .
      11994 11989 11999 11991  .0031231231231231846 10 1992 30 "19921030"     .
      11994 11989 11999 11994    .00850197581128001 11 1992  2 "1992112"  11994
      12023 12018 12028 12018   .009871900340815646 11 1992 26 "19921126"     .
      12023 12018 12028 12019    .01477947166298145 11 1992 27 "19921127"     .
      12023 12018 12028 12022   .003096330275229312 11 1992 30 "19921130"     .
      12023 12018 12028 12023   .011546816051217618 12 1992  1 "1992121"  12023
      12023 12018 12028 12024   .004746835443037994 12 1992  2 "1992122"      .
      12023 12018 12028 12025   .006299212598425222 12 1992  3 "1992123"      .
      12032 12027 12037 12031   .004243913334822375 12 1992  9 "1992129"      .
      12032 12027 12037 12032   .003781138790035625 12 1992 10 "19921210" 12032
      12032 12027 12037 12033  -.005096388211832572 12 1992 11 "19921211" 12033
      12032 12027 12037 12036 -.0015590200445434362 12 1992 14 "19921214"     .
      12032 12027 12037 12037  .0006691947356681048 12 1992 15 "19921215"     .
      12033 12028 12038 12031   .004243913334822375 12 1992  9 "1992129"      .
      12033 12028 12038 12032   .003781138790035625 12 1992 10 "19921210" 12032
      12033 12028 12038 12033  -.005096388211832572 12 1992 11 "19921211" 12033
      12033 12028 12038 12036 -.0015590200445434362 12 1992 14 "19921214"     .
      12033 12028 12038 12037  .0006691947356681048 12 1992 15 "19921215"     .
      12033 12028 12038 12038   .003566651805617559 12 1992 16 "19921216"     .
      12046 12041 12051 12043   .001111852346008545 12 1992 21 "19921221"     .
      12046 12041 12051 12044  .0006663705019991367 12 1992 22 "19921222"     .
      12046 12041 12051 12045   .005660377358490464 12 1992 23 "19921223"     .

      Comment


      • #4
        I'm not in finance so I don't know where you are going with this. If you want a zero in there, try:
        Code:
        gen days_from_event = date - Event_Date
        Also, if you want windows based on business dates, you'll have to learn about Stata's business calendars. See this recent thread about estimation and event windows.

        Comment

        Working...
        X