Announcement

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

  • Creating Eventwindows & Lagged Dummies (Event Study)

    Hello Everyone,

    I am new to this forum, so if I missed anything from the FAQ section regarding how to post problems here, please let me know.

    I am currently working on an Event Study by examaing the effect of dividend payments on trading volumes. Since I'm not working with STATA on a regular basis, I ran into some problems during the data preparation.

    My baseline datasheet contains the company id & name, date, a dummy which indicates the event date, prices, volumes and several dummies to indicate properties of the dividend (like taxes).
    Here an example of my datasheet:

    input float co_id str19 security float date str8 year double(unadjusted_price adjusted_price volume) int dividend_date byte tax float(days_co co_ret estimationwindow eventwindow twodayeventwindow onedayeventwindow)
    1 "1&1 DRILLISCH" 17532 "01012008" 5.5 5.5 . 0 . 1 . 0 0 0 0
    1 "1&1 DRILLISCH" 17533 "02012008" 5.2 5.2 86.4 0 . 2 -.05608947 0 0 0 0
    1 "1&1 DRILLISCH" 17534 "03012008" 5.42 5.42 144.4 0 . 3 .04143719 0 0 0 0
    1 "1&1 DRILLISCH" 17535 "04012008" 5.25 5.25 195 0 . 4 -.03186774 0 0 0 0
    1 "1&1 DRILLISCH" 17538 "07012008" 4.96 4.96 221.5 0 . 5 -.05682234 0 0 0 0
    1 "1&1 DRILLISCH" 17539 "08012008" 5.05 5.05 244.4 0 . 6 .017982503 0 0 0 0
    1 "1&1 DRILLISCH" 17540 "09012008" 4.94 4.94 108.3 0 . 7 -.02202291 0 0 0 0
    1 "1&1 DRILLISCH" 17541 "10012008" 4.96 4.96 259.6 0 . 8 .0040404093 0 0 0 0
    1 "1&1 DRILLISCH" 17542 "11012008" 4.64 4.64 276.2 0 . 9 -.066691376 0 0 0 0
    1 "1&1 DRILLISCH" 17545 "14012008" 4.61 4.61 177.7 0 . 10 -.00648651 0 0 0 0
    1 "1&1 DRILLISCH" 17546 "15012008" 4.46 4.46 274.4 0 . 11 -.03307909 0 0 0 0
    1 "1&1 DRILLISCH" 17547 "16012008" 4.39 4.39 207.1 0 . 12 -.015819538 0 0 0 0
    1 "1&1 DRILLISCH" 17548 "17012008" 4.22 4.22 160.4 0 . 13 -.0394941 0 0 0 0
    1 "1&1 DRILLISCH" 17549 "18012008" 4.12 4.12 148.3 0 . 14 -.023981964 0 0 0 0
    1 "1&1 DRILLISCH" 17552 "21012008" 3.95 3.95 283.4 0 . 15 -.04213759 0 0 0 0
    1 "1&1 DRILLISCH" 17553 "22012008" 4.25 4.25 699.9 0 . 16 .07320341 0 0 0 0
    1 "1&1 DRILLISCH" 17554 "23012008" 4.05 4.05 466.4 0 . 17 -.0482021 0 0 0 0
    1 "1&1 DRILLISCH" 17555 "24012008" 4.23 4.23 65.3 0 . 18 .04348511 0 0 0 0
    1 "1&1 DRILLISCH" 17556 "25012008" 4.43 4.43 265.7 0 . 19 .04619759 0 0 0 0
    1 "1&1 DRILLISCH" 17559 "28012008" 4.41 4.41 68.8 0 . 20 -.0045248945 0 0 0 0
    1 "1&1 DRILLISCH" 17560 "29012008" 4.56 4.56 41.2 0 . 21 .033447932 0 0 0 0
    1 "1&1 DRILLISCH" 17561 "30012008" 4.35 4.35 28.5 0 . 22 -.04714678 0 0 0 0
    1 "1&1 DRILLISCH" 17562 "31012008" 4.31 4.31 69.4 0 . 23 -.009237941 0 0 0 0
    1 "1&1 DRILLISCH" 17563 "01022008" 4.39 4.39 64.7 0 . 24 .018391322 0 0 0 0
    1 "1&1 DRILLISCH" 17566 "04022008" 4.38 4.38 45.8 0 . 25 -.0022805028 0 0 0 0
    1 "1&1 DRILLISCH" 17567 "05022008" 4.05 4.05 100.1 0 . 26 -.07833184 0 0 0 0
    1 "1&1 DRILLISCH" 17568 "06022008" 4.17 4.17 54 0 . 27 .029199155 0 0 0 0
    1 "1&1 DRILLISCH" 17569 "07022008" 4.03 4.03 105.1 0 . 28 -.03414966 0 0 0 0
    1 "1&1 DRILLISCH" 17570 "08022008" 3.99 3.99 61.3 0 . 29 -.009975145 0 0 0 0
    1 "1&1 DRILLISCH" 17573 "11022008" 4.03 4.03 32.1 0 . 30 .009975145 0 0 0 0
    1 "1&1 DRILLISCH" 17574 "12022008" 4.07 4.07 106.2 0 . 31 .009876624 0 0 0 0
    1 "1&1 DRILLISCH" 17575 "13022008" 4.14 4.14 52.2 0 . 32 .017052788 0 0 0 0
    1 "1&1 DRILLISCH" 17576 "14022008" 4.34 4.34 148.5 0 . 33 .04717856 0 0 0 0
    1 "1&1 DRILLISCH" 17577 "15022008" 4.25 4.25 62.2 0 . 34 -.020955365 0 0 0 0
    1 "1&1 DRILLISCH" 17580 "18022008" 4.29 4.29 69.9 0 . 35 .00936775 0 0 0 0
    1 "1&1 DRILLISCH" 17581 "19022008" 4.27 4.27 236.4 0 . 36 -.004672906 0 0 0 0
    1 "1&1 DRILLISCH" 17582 "20022008" 4.42 4.42 151.4 0 . 37 .034525868 0 0 0 0
    1 "1&1 DRILLISCH" 17583 "21022008" 4.35 4.35 88.9 0 . 38 -.01596385 0 0 0 0
    1 "1&1 DRILLISCH" 17584 "22022008" 4.27 4.27 99.5 0 . 39 -.018562017 0 0 0 0
    1 "1&1 DRILLISCH" 17587 "25022008" 4.4 4.4 41.7 0 . 40 .029990714 0 0 0 0
    1 "1&1 DRILLISCH" 17588 "26022008" 4.6 4.6 166.3 0 . 41 .04445176 0 0 0 0
    1 "1&1 DRILLISCH" 17589 "27022008" 4.5 4.5 113 0 . 42 -.02197891 0 0 0 0
    1 "1&1 DRILLISCH" 17590 "28022008" 4.76 4.76 377.5 0 . 43 .05617027 0 0 0 0
    1 "1&1 DRILLISCH" 17591 "29022008" 4.73 4.73 397.5 0 . 44 -.006322466 0 0 0 0
    1 "1&1 DRILLISCH" 17594 "03032008" 4.67 4.67 264.5 0 . 45 -.01276613 1 0 0 0
    1 "1&1 DRILLISCH" 17595 "04032008" 4.69 4.69 70.7 0 . 46 .004273511 1 0 0 0
    1 "1&1 DRILLISCH" 17596 "05032008" 4.73 4.73 251.9 0 . 47 .00849262 1 0 0 0
    1 "1&1 DRILLISCH" 17597 "06032008" 4.34 4.34 148 0 . 48 -.08605085 1 0 0 0
    1 "1&1 DRILLISCH" 17598 "07032008" 4.2 4.2 96.7 0 . 49 -.032789823 1 0 0 0
    1 "1&1 DRILLISCH" 17601 "10032008" 4.05 4.05 99.2 0 . 50 -.036367644 1 0 0 0
    1 "1&1 DRILLISCH" 17602 "11032008" 4.24 4.24 134.6 0 . 51 .04584639 1 0 0 0
    1 "1&1 DRILLISCH" 17603 "12032008" 4.24 4.24 97.2 0 . 52 0 1 0 0 0
    1 "1&1 DRILLISCH" 17604 "13032008" 4.16 4.16 83 0 . 53 -.019048195 1 0 0 0
    1 "1&1 DRILLISCH" 17605 "14032008" 4.31 4.31 43.1 0 . 54 .035422828 1 0 0 0
    1 "1&1 DRILLISCH" 17608 "17032008" 4.15 4.15 57.6 0 . 55 -.03782957 1 0 0 0
    1 "1&1 DRILLISCH" 17609 "18032008" 4.18 4.18 103.4 0 . 56 .007202912 1 0 0 0
    1 "1&1 DRILLISCH" 17610 "19032008" 4.05 4.05 106.8 0 . 57 -.031594366 1 0 0 0
    1 "1&1 DRILLISCH" 17611 "20032008" 4.09 4.09 53.7 0 . 58 .00982809 1 0 0 0
    1 "1&1 DRILLISCH" 17612 "21032008" 4.09 4.09 . 0 . 59 0 1 0 0 0
    1 "1&1 DRILLISCH" 17615 "24032008" 4.09 4.09 . 0 . 60 0 1 0 0 0
    1 "1&1 DRILLISCH" 17616 "25032008" 4.46 4.46 104.4 0 . 61 .0866038 1 0 0 0
    1 "1&1 DRILLISCH" 17617 "26032008" 4.4 4.4 154.7 0 . 62 -.013544225 1 0 0 0
    1 "1&1 DRILLISCH" 17618 "27032008" 4.31 4.31 83.3 0 . 63 -.020666637 1 0 0 0
    1 "1&1 DRILLISCH" 17619 "28032008" 4.34 4.34 72.1 0 . 64 .006936444 1 0 0 0
    1 "1&1 DRILLISCH" 17622 "31032008" 4.43 4.43 86 0 . 65 .020525236 1 0 0 0
    1 "1&1 DRILLISCH" 17623 "01042008" 4.56 4.56 140.4 0 . 66 .02892304 1 0 0 0
    1 "1&1 DRILLISCH" 17624 "02042008" 4.29 4.29 136.2 0 . 67 -.06103589 1 0 0 0
    1 "1&1 DRILLISCH" 17625 "03042008" 4.17 4.17 119.7 0 . 68 -.028370697 1 0 0 0
    1 "1&1 DRILLISCH" 17626 "04042008" 4.37 4.37 182.6 0 . 69 .04684697 1 0 0 0
    1 "1&1 DRILLISCH" 17629 "07042008" 4.75 4.75 153.8 0 . 70 .0833816 1 0 0 0
    1 "1&1 DRILLISCH" 17630 "08042008" 4.6 4.6 86.8 0 . 71 -.032088313 1 0 0 0
    1 "1&1 DRILLISCH" 17631 "09042008" 4.65 4.65 46.3 0 . 72 .010810916 1 0 0 0
    1 "1&1 DRILLISCH" 17632 "10042008" 4.6 4.6 52.4 0 . 73 -.010810916 1 0 0 0
    1 "1&1 DRILLISCH" 17633 "11042008" 4.54 4.54 51.3 0 . 74 -.01312929 1 0 0 0
    1 "1&1 DRILLISCH" 17636 "14042008" 4.45 4.45 77 0 . 75 -.020022916 1 0 0 0
    1 "1&1 DRILLISCH" 17637 "15042008" 4.39 4.39 58.9 0 . 76 -.01357487 1 0 0 0
    1 "1&1 DRILLISCH" 17638 "16042008" 4.27 4.27 103.5 0 . 77 -.0277154 1 0 0 0
    1 "1&1 DRILLISCH" 17639 "17042008" 4.34 4.34 30.2 0 . 78 .016260521 1 0 0 0
    1 "1&1 DRILLISCH" 17640 "18042008" 4.35 4.35 74 0 . 79 .002301497 1 0 0 0
    1 "1&1 DRILLISCH" 17643 "21042008" 4.3 4.3 46 0 . 80 -.011560823 1 0 0 0
    1 "1&1 DRILLISCH" 17644 "22042008" 4.37 4.37 51.8 0 . 81 .016147986 1 0 0 0
    1 "1&1 DRILLISCH" 17645 "23042008" 4.42 4.42 32.1 0 . 82 .011376687 1 0 0 0
    1 "1&1 DRILLISCH" 17646 "24042008" 4.35 4.35 30.1 0 . 83 -.01596385 1 0 0 0
    1 "1&1 DRILLISCH" 17647 "25042008" 4.35 4.35 34.9 0 . 84 0 1 0 0 0
    1 "1&1 DRILLISCH" 17650 "28042008" 4.1 4.1 193.1 0 . 85 -.05918887 1 0 0 0
    1 "1&1 DRILLISCH" 17651 "29042008" 3.75 3.75 524.1 0 . 86 -.08923113 1 0 0 0
    1 "1&1 DRILLISCH" 17652 "30042008" 3.9 3.9 186.6 0 . 87 .03922071 1 0 0 0
    1 "1&1 DRILLISCH" 17653 "01052008" 3.9 3.9 . 0 . 88 0 1 0 0 0
    1 "1&1 DRILLISCH" 17654 "02052008" 3.9 3.9 75.3 0 . 89 0 1 0 0 0
    1 "1&1 DRILLISCH" 17657 "05052008" 4.03 4.03 49.3 0 . 90 .032789823 1 0 0 0
    1 "1&1 DRILLISCH" 17658 "06052008" 4 4 27.7 0 . 91 -.007472015 1 0 0 0
    1 "1&1 DRILLISCH" 17659 "07052008" 4.2 4.2 71.1 0 . 92 .04879016 1 0 0 0
    1 "1&1 DRILLISCH" 17660 "08052008" 4.22 4.22 8 0 . 93 .004750603 1 0 0 0
    1 "1&1 DRILLISCH" 17661 "09052008" 4.26 4.26 49.6 0 . 94 .009434032 1 0 0 0
    1 "1&1 DRILLISCH" 17664 "12052008" 4.43 4.43 32.1 0 . 95 .03913042 1 0 0 0
    1 "1&1 DRILLISCH" 17665 "13052008" 4.48 4.48 32.5 0 . 96 .011223462 1 0 0 0
    1 "1&1 DRILLISCH" 17666 "14052008" 4.4 4.4 169.8 0 . 97 -.018018505 1 0 0 0
    1 "1&1 DRILLISCH" 17667 "15052008" 4.54 4.54 245.5 0 . 98 .03132247 1 0 0 0
    1 "1&1 DRILLISCH" 17668 "16052008" 4.69 4.69 65.1 0 . 99 .03250557 1 0 0 0
    1 "1&1 DRILLISCH" 17671 "19052008" 4.64 4.64 84.2 0 . 100 -.010718216 1 1 0 0


    First Problem:
    I tried to create event-windows around the event date (ex-dividend date) and started with a code like this, where the dividend_date dummy equals 1 at the ex-dividend date:

    First approach:

    gen eventwindow=0
    replace eventwindow=1 if dividend_date[_n-10]==1
    replace eventwindow=1 if dividend_date[_n-9]==1
    replace eventwindow=1 if dividend_date[_n-8]==1
    replace eventwindow=1 if dividend_date[_n-7]==1
    replace eventwindow=1 if dividend_date[_n-6]==1
    replace eventwindow=1 if dividend_date[_n-5]==1
    replace eventwindow=1 if dividend_date[_n-4]==1
    replace eventwindow=1 if dividend_date[_n-3]==1
    replace eventwindow=1 if dividend_date[_n-2]==1
    replace eventwindow=1 if dividend_date[_n-1]==1
    replace eventwindow=1 if dividend_date==1
    replace eventwindow=1 if dividend_date[_n+1]==1
    replace eventwindow=1 if dividend_date[_n+2]==1
    replace eventwindow=1 if dividend_date[_n+3]==1
    replace eventwindow=1 if dividend_date[_n+4]==1
    replace eventwindow=1 if dividend_date[_n+5]==1
    replace eventwindow=1 if dividend_date[_n+6]==1
    replace eventwindow=1 if dividend_date[_n+7]==1
    replace eventwindow=1 if dividend_date[_n+8]==1
    replace eventwindow=1 if dividend_date[_n+9]==1
    replace eventwindow=1 if dividend_date[_n+10]==1

    This approach seemed to work at first but is rather inefficient when it comes to larger windows. So I tried the following approach, which led to my first problem:

    Second approach:

    sort co_id date
    by co_id: gen datenum=_n
    by co_id: gen target=datenum if dividend_date==1
    egen td=min(target), by(co_id)
    drop target
    gen dif=datenum-td

    The dif variable counts the number of days from the observation to the event date (and further), with which I could create the dummies more efficiently. However this formular only works for one event per company. Since I'm analyzing dividend payments over seven years, I have obviously more than one event per company and STATA takes the first target date, calculates the difference from the other observations and ignores all following targets. My idea would be to create a "time-frame" around the calculation of dif, so that it can calculate the new difference for the next target (e.g. only calculate the difference 100 days around the event date). However, I am not sure how to do this.

    To be more precise, one problem appears by the creation of the tax dummy (which indicates if a dividend is taxable or not). If the dividend is taxable the dummy equals one, if the dividend is tax free, it equals zero and for observations with no dividend payments it has missing values. Since I generate interactions between the tax dummy and the window dummies, the tax dummy has to take on the value 1 or 0 for a specific number of days around the event day, according to the lenght of the window (otherwise the interaction would be always 0 except for the event date --> all interactions would be the same). Following my first approach, I don't know how to lag this tax dummy around the event date, so I tried to use the second approach.


    Second Problem:
    Since my eventwindow dummy from above is binary, I (think I) can only include it as a normal variable in my regression. However, I want my regression to take the baseline effects of every lagged value of this window into account (Like the i.year variable would do it for every year). I am not sure how to generate my dummy (or write my regression function) in a way that every lagged value (negative and positve lag --> from -10 days to +10 days) appears in my regression output.

    I hope I provided enough information for you to understand my problem.
    Thank you very much for your help!


  • #2
    Welcome to Statalist.

    Below is sample code that leverages Stata time series variable notation to accomplish what you want, I think. (See the output of help tsvarlist for details on time series variable notation. I have reduced your data to two months, dropped variables I don't need for this demonstration, and set dividends on the 15th of both months, since your example data showed no days with dividends. Also, your example data covers business days. There's a whole Stata framework for using business calendars that I am going to ignore and instead create a pseud-date variable that numbers the "workdays" for each company sequentially,
    Code:
    cls
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float co_id str19 security float date double volume int dividend_date
    1 "1&1 DRILLISCH" 17532     . 0
    1 "1&1 DRILLISCH" 17533  86.4 0
    1 "1&1 DRILLISCH" 17534 144.4 0
    1 "1&1 DRILLISCH" 17535   195 0
    1 "1&1 DRILLISCH" 17538 221.5 0
    1 "1&1 DRILLISCH" 17539 244.4 0
    1 "1&1 DRILLISCH" 17540 108.3 0
    1 "1&1 DRILLISCH" 17541 259.6 0
    1 "1&1 DRILLISCH" 17542 276.2 0
    1 "1&1 DRILLISCH" 17545 177.7 0
    1 "1&1 DRILLISCH" 17546 274.4 1
    1 "1&1 DRILLISCH" 17547 207.1 0
    1 "1&1 DRILLISCH" 17548 160.4 0
    1 "1&1 DRILLISCH" 17549 148.3 0
    1 "1&1 DRILLISCH" 17552 283.4 0
    1 "1&1 DRILLISCH" 17553 699.9 0
    1 "1&1 DRILLISCH" 17554 466.4 0
    1 "1&1 DRILLISCH" 17555  65.3 0
    1 "1&1 DRILLISCH" 17556 265.7 0
    1 "1&1 DRILLISCH" 17559  68.8 0
    1 "1&1 DRILLISCH" 17560  41.2 0
    1 "1&1 DRILLISCH" 17561  28.5 0
    1 "1&1 DRILLISCH" 17562  69.4 0
    1 "1&1 DRILLISCH" 17563  64.7 0
    1 "1&1 DRILLISCH" 17566  45.8 0
    1 "1&1 DRILLISCH" 17567 100.1 0
    1 "1&1 DRILLISCH" 17568    54 0
    1 "1&1 DRILLISCH" 17569 105.1 0
    1 "1&1 DRILLISCH" 17570  61.3 0
    1 "1&1 DRILLISCH" 17573  32.1 0
    1 "1&1 DRILLISCH" 17574 106.2 0
    1 "1&1 DRILLISCH" 17575  52.2 0
    1 "1&1 DRILLISCH" 17576 148.5 0
    1 "1&1 DRILLISCH" 17577  62.2 1
    1 "1&1 DRILLISCH" 17580  69.9 0
    1 "1&1 DRILLISCH" 17581 236.4 0
    1 "1&1 DRILLISCH" 17582 151.4 0
    1 "1&1 DRILLISCH" 17583  88.9 0
    1 "1&1 DRILLISCH" 17584  99.5 0
    1 "1&1 DRILLISCH" 17587  41.7 0
    1 "1&1 DRILLISCH" 17588 166.3 0
    1 "1&1 DRILLISCH" 17589   113 0
    1 "1&1 DRILLISCH" 17590 377.5 0
    1 "1&1 DRILLISCH" 17591 397.5 0
    end
    format %td date
    
    bysort co_id (date): generate busday = _n
    xtset co_id busday
    
    regress volume L(-5/5).dividend_date
    Code:
    . bysort co_id (date): generate busday = _n
    
    . xtset co_id busday
           panel variable:  co_id (strongly balanced)
            time variable:  busday, 1 to 44
                    delta:  1 unit
    
    . 
    . regress volume L(-5/5).dividend_date
    
          Source |       SS           df       MS      Number of obs   =        34
    -------------+----------------------------------   F(11, 22)       =      0.69
           Model |  162182.443        11  14743.8584   Prob > F        =    0.7315
        Residual |  468083.172        22  21276.5078   R-squared       =    0.2573
    -------------+----------------------------------   Adj R-squared   =   -0.1140
           Total |  630265.614        33   19098.958   Root MSE        =    145.86
    
    -------------------------------------------------------------------------------
           volume |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
    dividend_date |
              F5. |   38.26667    111.406     0.34   0.734    -192.7752    269.3086
              F4. |  -44.38333    111.406    -0.40   0.694    -275.4252    186.6586
              F3. |   68.31667    111.406     0.61   0.546    -162.7252    299.3586
              F2. |   49.61667    111.406     0.45   0.660    -181.4252    280.6586
              F1. |   48.51667    111.406     0.44   0.667    -182.5252    279.5586
              --. |   53.71667    111.406     0.48   0.634    -177.3252    284.7586
              L1. |   23.91667    111.406     0.21   0.832    -207.1252    254.9586
              L2. |   83.81667    111.406     0.75   0.460    -147.2252    314.8586
              L3. |   35.26667    111.406     0.32   0.755    -195.7752    266.3086
              L4. |   71.56667    111.406     0.64   0.527    -159.4752    302.6086
              L5. |   285.1167    111.406     2.56   0.018     54.07477    516.1586
                  |
            _cons |   114.5833   42.10751     2.72   0.012      27.2577     201.909
    -------------------------------------------------------------------------------

    Comment


    • #3
      Hello William,

      thank you very much for your quick response!

      The lag operator in your regression function would definetly solve the problem with the eventwindow dummy in my regression (Problem 2)

      I am not quite sure if I miss some information "between the lines" in your answer (can I use the lag operator in your regression to create dummies - this would solve the problem (I think)?), but your solution with the pseudo date etc. was already given in my question.
      Therefore, I am still struggling with problem 1 of my question:

      "To be more precise, one problem appears during the creation of the tax dummy (which indicates if a dividend is taxable or not). If the dividend is taxable the dummy equals one, if the dividend is tax free, it equals zero and for observations with no dividend payments it has missing values. Since I generate interactions between the tax dummy and the window dummies, the tax dummy has to take on the value 1 or 0 for a specific number of days around the event day, according to the lenght of the window (otherwise the interaction would be always 0 except for the event date --> all interactions would be the same). Following my first approach, I don't know how to lag this tax dummy around the event date, so I tried to use the second approach."

      Comment


      • #4
        I lost sight of your "first problem" in post #1 - the "second problem" is what caught my attention. That, coupled the complicated approach to creating the event window, led to my example code that avoids creating the event window.

        With that said, I am finding it difficult to envision exactly what you have in mind, in part because, as I noted, your example data didn't have an example of a dividend date, and in part because even the best descriptions of data are no substitute for an actual example of the data, one that includes not only the inputs but also makes it clear what the objective is as well.

        In particular I do not understand whether the interaction between the tax dummy and the window dummy pertains to the creation of the tax dummy using the value of tax on the day of the event, or an interaction term between the window dummy and the tax dummy in your regression model.

        I suggest you read into Stata the small example data from post #2 (including the format command) and then - perhaps just using the Data Editor window - recreate the tax column, making one of the two events taxable and the other nontaxable, and then, assuming a 3-day lead/lag period to minimize effort, create the eventwindow dummy you want (presumably 1's on the event day and the 3 days before and after, all else zero), the taxdummy you want (this is where I have prob;ems), and the "interaction" between the two - if b. Don't worry about how to include the leads/lags in your regression, just use this to indicate for each day in the window around your regression what you want that day's values to be. And then use the dataex command to post a reply with the resulting dataset including the additional variables.

        Comment


        • #5
          Thanks for the answer.

          I prepared your data example as you said:
          tax dummy indicates taxable dividend with value 1, non taxables with value 0 and missing values for no dividends (first event is taxable, second is not). The eventwindow is equal to 1 for the interval -3/+3 days around the dividend date.
          The interaction term then, because of the tax dummy, which only has a value for the dividend date, has missing values during the eventwindow and only a value for the dividend date, since that is the only observation where the tax daummy has a value.
          My problem is how to lead/lag this tax dummy efficiently around the dividend day (for value 1 AND value 0), so that the interaction has values for the length of the eventwindow. (If I have a 3-day lead/lag window the tax dummy has to take on the value (either 1 or 0) for a 3-day lead/lag period around the event date as well.

          I hope this makes it clear.

          Data:
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input float co_id str19 security float date double volume int dividend_date float(tax eventwindow taxwin busday)
          1 "1&1 DRILLISCH" 17532     . 0 . 0 .  1
          1 "1&1 DRILLISCH" 17533  86.4 0 . 0 .  2
          1 "1&1 DRILLISCH" 17534 144.4 0 . 0 .  3
          1 "1&1 DRILLISCH" 17535   195 0 . 0 .  4
          1 "1&1 DRILLISCH" 17538 221.5 0 . 0 .  5
          1 "1&1 DRILLISCH" 17539 244.4 0 . 0 .  6
          1 "1&1 DRILLISCH" 17540 108.3 0 . 0 .  7
          1 "1&1 DRILLISCH" 17541 259.6 0 . 1 .  8
          1 "1&1 DRILLISCH" 17542 276.2 0 . 1 .  9
          1 "1&1 DRILLISCH" 17545 177.7 0 . 1 . 10
          1 "1&1 DRILLISCH" 17546 274.4 1 1 1 1 11
          1 "1&1 DRILLISCH" 17547 207.1 0 . 1 . 12
          1 "1&1 DRILLISCH" 17548 160.4 0 . 1 . 13
          1 "1&1 DRILLISCH" 17549 148.3 0 . 1 . 14
          1 "1&1 DRILLISCH" 17552 283.4 0 . 0 . 15
          1 "1&1 DRILLISCH" 17553 699.9 0 . 0 . 16
          1 "1&1 DRILLISCH" 17554 466.4 0 . 0 . 17
          1 "1&1 DRILLISCH" 17555  65.3 0 . 0 . 18
          1 "1&1 DRILLISCH" 17556 265.7 0 . 0 . 19
          1 "1&1 DRILLISCH" 17559  68.8 0 . 0 . 20
          1 "1&1 DRILLISCH" 17560  41.2 0 . 0 . 21
          1 "1&1 DRILLISCH" 17561  28.5 0 . 0 . 22
          1 "1&1 DRILLISCH" 17562  69.4 0 . 0 . 23
          1 "1&1 DRILLISCH" 17563  64.7 0 . 0 . 24
          1 "1&1 DRILLISCH" 17566  45.8 0 . 0 . 25
          1 "1&1 DRILLISCH" 17567 100.1 0 . 0 . 26
          1 "1&1 DRILLISCH" 17568    54 0 . 0 . 27
          1 "1&1 DRILLISCH" 17569 105.1 0 . 0 . 28
          1 "1&1 DRILLISCH" 17570  61.3 0 . 0 . 29
          1 "1&1 DRILLISCH" 17573  32.1 0 . 0 . 30
          1 "1&1 DRILLISCH" 17574 106.2 0 . 1 . 31
          1 "1&1 DRILLISCH" 17575  52.2 0 . 1 . 32
          1 "1&1 DRILLISCH" 17576 148.5 0 . 1 . 33
          1 "1&1 DRILLISCH" 17577  62.2 1 0 1 0 34
          1 "1&1 DRILLISCH" 17580  69.9 0 . 1 . 35
          1 "1&1 DRILLISCH" 17581 236.4 0 . 1 . 36
          1 "1&1 DRILLISCH" 17582 151.4 0 . 1 . 37
          1 "1&1 DRILLISCH" 17583  88.9 0 . 0 . 38
          1 "1&1 DRILLISCH" 17584  99.5 0 . 0 . 39
          1 "1&1 DRILLISCH" 17587  41.7 0 . 0 . 40
          1 "1&1 DRILLISCH" 17588 166.3 0 . 0 . 41
          1 "1&1 DRILLISCH" 17589   113 0 . 0 . 42
          1 "1&1 DRILLISCH" 17590 377.5 0 . 0 . 43
          1 "1&1 DRILLISCH" 17591 397.5 0 . 0 . 44
          end
          format %td date

          Thank you again for your help!

          Comment


          • #6
            Using the rangestat command from SSC (ssc describe rangestat for a description and the installation command) makes this straightforward. Applied to your data in post #5, the command below creates ew and tw which seem to be what you want.
            Code:
            rangestat (max) ew=dividend_date tw=tax, interval(busday -3 3) by(co_id)
            With that said, I do not know how an "event analysis" is conducted. But if the tax window variable is included among the variables in your analysis, then every observation for which the value is missing - that is, every observation outside the event window - will be deleted from the analysis, as described in the output of help missing.

            Most Stata commands ignore observations that are missing in one or more of the variables referred to in the command.
            And this doesn't solve the problem of including all the event window days in the equation. My own inclination would be
            Code:
            xtset co_id busday
            replace dividend_date=2 if tax==1
            regress volume L(-3/3)ib0.dividend_date
            which gives a set of 7 coefficients for dividend date=1 (corresponding to tax=0) and 7 for dividend_date=2 (corresponding to tax=1).

            Comment


            • #7
              Thank you very much!
              The rangestat command is exactly what I was looking for. I understand your concern about the missing values, but my idea is to simply extend the variables in my regression with the rangestat command to the length of my estimation window (-65 +65 around the event date). This should solve the problem.
              However, since every company has its own volume values (obvisously), the regression hast to be conducted for each company individually (I think?) with a command like forevalues?

              Code:
              sort co_id
              summ co_id
              local total_co = `r(max)'
                    
              forvalues i = 1/`total_co' {
              
                    xtmixed lnvol dividend_date eventwindow wintax wincum twowintax onewintax tw cumex cumextax if co_id == `i' & estimationwindow==1
              
                    }
              (Don't worry about all the dummies like wincum, twowintax etc. these are just the dummies we were talking about previously (tax*eventwindow).)

              This approach however, gives me one output for each company (obviously). To be honest, I am not sure how to tell STATA that it has to account for each company individually in the regression so I recieve one output. Maybe it can be done with a simple bysort command?:

              Code:
              bys co_id : xtmixed lnvol dividend_date eventwindow wintax wincum twowintax onewintax tw cumex cumextax if estimationwindow==1
              I know this is a more specific question into event studies. Should I open a new thread for questions regarding my regression? If you want me to provide an example data with two companies please let me know.

              It is quite frustrating to know theoretically what to do, but to not know how to tell STATA to do what I have in mind...

              Comment

              Working...
              X