Announcement

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

  • Event study - multiple cumulative abnormal return windows

    Dear all,

    I am doing an event study and I calculated my abnormal returns for each day in my event window. Now I would like to have cumulative abnormal returns, I do know how to get total cumulative abnormal returns but I would like to get cumulative abnormal returns for day 0 and 1, for day 0 + 1 + 2, day 0 + 1 + 2 + 3 etc.
    How can I get this? I did generate the separate days, see my data example.
    I hope this is clear and I hope you can help me. Thanks!

    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(group_id days abnormal_return ar0 ar1 ar2 ar3 ar4 ar5)
    1 -5 -.8582855 . . . . . .
    1 -4 .16700104 . . . . . .
    1 -3 .1703391 . . . . . .
    1 -2 1.9902632 . . . . . .
    1 -1 -1.768956 . . . . . .
    1 0 3.237539 3.237539 . . . . .
    1 1 -3.343374 . -3.343374 . . . .
    1 2 3.76568 . . 3.76568 . . .
    1 3 -2.884671 . . . -2.884671 . .
    1 4 -2.3570244 . . . . -2.3570244 .
    1 5 -1.8902892 . . . . . -1.8902892
    2 -5 -2.621948 . . . . . .
    2 -4 -4.3372827 . . . . . .
    2 -3 -3.202744 . . . . . .
    2 -2 .15659374 . . . . . .
    2 -1 2.008903 . . . . . .
    2 0 -2.81355 -2.81355 . . . . .
    2 1 -1.2368627 . -1.2368627 . . . .
    2 2 2.4508095 . . 2.4508095 . . .
    2 3 -1.8451455 . . . -1.8451455 . .
    2 4 .9693156 . . . . .9693156 .
    2 5 1.8602867 . . . . . 1.8602867
    3 -5 2.3462427 . . . . . .
    3 -4 .7954761 . . . . . .
    3 -3 2.719074 . . . . . .
    3 -2 -.6082731 . . . . . .
    3 -1 .14762443 . . . . . .
    3 0 1.0986892 1.0986892 . . . . .
    3 1 1.5341017 . 1.5341017 . . . .
    3 2 -1.6110423 . . -1.6110423 . . .
    3 3 -.8279147 . . . -.8279147 . .
    3 4 -2.262677 . . . . -2.262677 .
    3 5 .923644 . . . . . .923644
    5 -5 -7.321589 . . . . . .
    5 -4 7.963714 . . . . . .
    5 -3 -1.246004 . . . . . .
    5 -2 -1.5393357 . . . . . .
    5 -1 4.6231594 . . . . . .
    5 0 .4869067 .4869067 . . . . .
    5 1 -.9067889 . -.9067889 . . . .
    5 2 -1.686836 . . -1.686836 . . .
    5 3 .1129115 . . . .1129115 . .
    5 4 -.43044415 . . . . -.43044415 .
    5 5 -.10070435 . . . . . -.10070435
    end
    [/CODE]

  • #2
    Nelleke:
    does the following code do what you want?
    Code:
    bysort group_id: gen x=sum(abnormal_return) if days>=0
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo, thank you. I just saw that I did not copy my example correctly. Well the idea is correct, but I want separate variables for it. Thus:
      1 variable that sums abnormal return on day 0 and day 1
      1 variable that sums abnormal return on day 0 and day 1 and day 2
      1 variable that sums abnormal return on day 0 and day 1 and day 2 and day 3
      1 variable that sums abnormal return on day 0 and day 1 and day 2 and day 3 and day 4 and day 5
      1 variable that sums abnormal return on day 0 and day 1 and day 2 and day 3 and day 4 and day 5
      ​​​​​​​​​​​​​​
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(group_id days abnormal_return ar0 ar1 ar2 ar3 ar4 ar5)
       1 -1  -1.768956          0          0          .          .          .          .
       1  2    3.76568          0          0    3.76568          .          .          .
       1  3  -2.884671          0          0          .  -2.884671          .          .
       1 -5  -.8582855          0          0          .          .          .          .
       1 -3   .1703391          0          0          .          .          .          .
       1 -2  1.9902632          0          0          .          .          .          .
       1  1  -3.343374          0  -3.343374          .          .          .          .
       1 -4  .16700104          0          0          .          .          .          .
       1  4 -2.3570244          0          0          .          . -2.3570244          .
       1  5 -1.8902892          0          0          .          .          . -1.8902892
       1  0   3.237539   3.237539          0          .          .          .          .
       2  2  2.4508095          0          0  2.4508095          .          .          .
       2  4   .9693156          0          0          .          .   .9693156          .
       2  1 -1.2368627          0 -1.2368627          .          .          .          .
       2 -4 -4.3372827          0          0          .          .          .          .
       2  5  1.8602867          0          0          .          .          .  1.8602867
       2 -1   2.008903          0          0          .          .          .          .
       2 -5  -2.621948          0          0          .          .          .          .
       2 -2  .15659374          0          0          .          .          .          .
       2  3 -1.8451455          0          0          . -1.8451455          .          .
       2 -3  -3.202744          0          0          .          .          .          .
       2  0   -2.81355   -2.81355          0          .          .          .          .
       3 -3   2.719074          0          0          .          .          .          .
       3 -1  .14762443          0          0          .          .          .          .
       3  5    .923644          0          0          .          .          .    .923644
       3  3  -.8279147          0          0          .  -.8279147          .          .
       3 -4   .7954761          0          0          .          .          .          .
       3 -5  2.3462427          0          0          .          .          .          .
       3  4  -2.262677          0          0          .          .  -2.262677          .
       3  2 -1.6110423          0          0 -1.6110423          .          .          .
       3  1  1.5341017          0  1.5341017          .          .          .          .
       3 -2  -.6082731          0          0          .          .          .          .
       3  0  1.0986892  1.0986892          0          .          .          .          .
      end

      Comment


      • #4
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input float(group_id days abnormal_return x)
         1 -1  -1.768956          .
         1  2    3.76568    3.76568
         1  3  -2.884671   .8810096
         1 -5  -.8582855          .
         1 -3   .1703391          .
         1 -2  1.9902632          .
         1  1  -3.343374 -2.4623644
         1 -4  .16700104          .
         1  4 -2.3570244  -4.819389
         1  5 -1.8902892  -6.709678
         1  0   3.237539 -3.4721394
         2  2  2.4508095  2.4508095
         2  4   .9693156   3.420125
         2  1 -1.2368627  2.1832623
         2 -4 -4.3372827          .
         2  5  1.8602867   4.043549
         2 -1   2.008903          .
         2 -5  -2.621948          .
         2 -2  .15659374          .
         2  3 -1.8451455  2.1984036
         2 -3  -3.202744          .
         2  0   -2.81355  -.6151461
         3 -3   2.719074          .
         3 -1  .14762443          .
         3  5    .923644    .923644
         3  3  -.8279147  .09572935
         3 -4   .7954761          .
         3 -5  2.3462427          .
         3  4  -2.262677 -2.1669476
         3  2 -1.6110423   -3.77799
         3  1  1.5341017 -2.2438881
         3 -2  -.6082731          .
         3  0  1.0986892  -1.145199
        end

        I just checked it and the code by Carlo, unfortunately, does not do what I want. For example, for day 0 the variable x should return the same value as the simple abnormal return on day 0. For day 1, I would expect the sum of the abnormal return of day 0 and day 1 but that is also not the case. What am I missing?

        Comment


        • #5
          Nelleke:
          you may want to try the following code:
          Code:
          input float(group_id days abnormal_return x)
           1 -1  -1.768956          .
           1  2    3.76568    3.76568
           1  3  -2.884671   .8810096
           1 -5  -.8582855          .
           1 -3   .1703391          .
           1 -2  1.9902632          .
           1  1  -3.343374 -2.4623644
           1 -4  .16700104          .
           1  4 -2.3570244  -4.819389
           1  5 -1.8902892  -6.709678
           1  0   3.237539 -3.4721394
           2  2  2.4508095  2.4508095
           2  4   .9693156   3.420125
           2  1 -1.2368627  2.1832623
           2 -4 -4.3372827          .
           2  5  1.8602867   4.043549
           2 -1   2.008903          .
           2 -5  -2.621948          .
           2 -2  .15659374          .
           2  3 -1.8451455  2.1984036
           2 -3  -3.202744          .
           2  0   -2.81355  -.6151461
           3 -3   2.719074          .
           3 -1  .14762443          .
           3  5    .923644    .923644
           3  3  -.8279147  .09572935
           3 -4   .7954761          .
           3 -5  2.3462427          .
           3  4  -2.262677 -2.1669476
           3  2 -1.6110423   -3.77799
           3  1  1.5341017 -2.2438881
           3 -2  -.6082731          .
           3  0  1.0986892  -1.145199
          end
          sort group_id days
          bysort group_id: g flag=1 if days>=0
          bysort group_id: replace flag=sum(flag) if flag!=.
          forval i = 1(1)6  {
          bysort group_id: g count`i'=sum( abnormal_return ) if flag<=`i'
          }
          forval i = 1(1)6  {
          bysort group_id: replace count`i'=. if flag[_n]!=`i'
          }
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Carlo, it worked! Thanks a lot.

            Comment

            Working...
            X