Announcement

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

  • Event Study - Multiple Dates

    Hi all,

    I've conducted an event study using this link https://dss.princeton.edu/online_hel...udy.html#clean, and at the end of it it turns out I do not have enough observations for the final CAR regression.

    I deviated from the tutorial as my data concerns a single index, whereas it was using the example of a sample of firms, so perhaps that caused the issue. Alternatively I wondered if it was the fact that I wanted to look at only the returns over 1 day (with multiple dates), and so the event window code read as "gen event_window=1 if dif>=-1 & dif<=0", is there any logical problem with this?

    In terms of what I wish to precisely achieve is to assess if there are CAR regarding macroeconomic events, read as irregular and multiple. The data is for one index. There are multiple events. I have price data, and % change from one price to the next. I only want to measure the change on the day of the event.

    Edit: I'm using Stata 13.0

    Disclaimer: I started a similar thread recently asking for assistance but was lacking code to be interrogated. I will link to this thread in that one.

    Many thanks,

    Toby


    Code:
    use eventdates, clear
    
    * Preparing the data
    sort company_id
    by company_id: gen eventcount=_N
    
    by company_id: keep if _n==1
    sort company_id
    keep company_id eventcount
    save eventcount
    
    use stockdata, clear
    sort company_id
    merge company_id using eventcount
    tab _merge
    keep if _merge==3
    drop _merge
    
    expand eventcount
    
    drop eventcount
    sort company_id date
    by company_id date: gen set=_n
    sort company_id set
    save stockdata2
    
    use eventdates, clear
    sort company_id
    by company_id: gen set=_n
    sort company_id set
    save eventdates2
    use stockdata2, clear
    merge company_id set using eventdates2
    tab _merge
    
    * Cleaning the data and calculating event and estimation windows
    gen date2 = date(date, "DMY")
    format date2 %td
    drop date
    rename date2 date
    
    
    sort company_id date
    by company_id: gen datenum=_n
    by company_id: gen target=datenum if date==event_date
    egen td=min(target), by(company_id)
    drop target
    gen dif=datenum-td
    
    by company_id: gen event_window=1 if dif>=-1 & dif<=0
    egen count_event_obs=count(event_window), by(company_id)
    by company_id: gen estimation_window=1 if dif<-30 & 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==.
    
    drop count_event_obs count_est_obs
    
    set more off /* this command just keeps stata from pausing after each screen of output */
    gen predicted_return=.
    egen id = group(group_id)
    /* for multiple event dates, use: egen id = group(group_id) */
    forvalues i=1(1)1
    
    l id company_id if id==`i' & dif==0
        reg ret market_return if id==`i' & estimation_window==1
        predict p if id==`i'
        replace predicted_return = p if id==`i' & event_window==1
        drop p
        
    gen abnormal_return= market_return -predicted_return if event_window==1
    by id: egen cumulative_abnormal_return = sum(abnormal_return)
    
    
    gen test =(1/sqrt(2)) * ( cumulative_abnormal_return /ar_sd)
    list company_id cumulative_abnormal_return test if dif==0
    Last edited by Toby Jones; 03 Jul 2018, 10:00.

  • #2
    Provide an example of your data using the dataex command. See FAQ 12.2 What to say about your data here https://www.statalist.org/forums/help#noanswer . Then, based on your example data, ask questions.

    Comment


    • #3
      [CODE]
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(eurostoxx market_return) byte(ecbannouncement company_id) float set int event_date byte _merge float(datenum date td dif event_window estimation_window predicted_return id abnormal_return cumulative_abnormal_return ar_sd test)
      287.81 3.08 0 1  65 18906 3 113109 14248 679 112430 0 0 . 1 . 0 . .
      287.81 3.08 0 1 109 17443 3 113157 14248 679 112478 0 0 . 1 . 0 . .
      287.81 3.08 0 1 198 15035 3 113182 14248 679 112503 0 0 . 1 . 0 . .
      287.81 3.08 0 1  52 19305 3 113057 14248 679 112378 0 0 . 1 . 0 . .
      287.81 3.08 0 1 243 14307 3 113058 14248 679 112379 0 0 . 1 . 0 . .
      287.81 3.08 0 1  48 19424 3 113126 14248 679 112447 0 0 . 1 . 0 . .
      287.81 3.08 0 1   2 21251 3 113203 14248 679 112524 0 0 . 1 . 0 . .
      287.81 3.08 0 1 108 17478 3 113169 14248 679 112490 0 0 . 1 . 0 . .
      287.81 3.08 0 1 130 16813 3 113039 14248 679 112360 0 0 . 1 . 0 . .
      287.81 3.08 0 1  78 18423 3 113110 14248 679 112431 0 0 . 1 . 0 . .
      287.81 3.08 0 1  79 18388 3 113166 14248 679 112487 0 0 . 1 . 0 . .
      287.81 3.08 0 1  24 20242 3 113163 14248 679 112484 0 0 . 1 . 0 . .
      287.81 3.08 0 1  73 18640 3 113068 14248 679 112389 0 0 . 1 . 0 . .
      287.81 3.08 0 1  33 19907 3 113113 14248 679 112434 0 0 . 1 . 0 . .
      287.81 3.08 0 1   8 20978 3 113009 14248 679 112330 0 0 . 1 . 0 . .
      287.81 3.08 0 1  64 18934 3 113046 14248 679 112367 0 0 . 1 . 0 . .
      287.81 3.08 0 1  68 18815 3 113060 14248 679 112381 0 0 . 1 . 0 . .
      287.81 3.08 0 1 135 16652 3 113004 14248 679 112325 0 0 . 1 . 0 . .
      287.81 3.08 0 1 187 15189 3 113026 14248 679 112347 0 0 . 1 . 0 . .
      287.81 3.08 0 1 161 15861 3 113171 14248 679 112492 0 0 . 1 . 0 . .
      287.81 3.08 0 1 179 15315 3 112998 14248 679 112319 0 0 . 1 . 0 . .
      287.81 3.08 0 1  14 20705 3 113001 14248 679 112322 0 0 . 1 . 0 . .
      287.81 3.08 0 1  88 18080 3 113066 14248 679 112387 0 0 . 1 . 0 . .
      287.81 3.08 0 1 182 15259 3 113144 14248 679 112465 0 0 . 1 . 0 . .
      287.81 3.08 0 1 119 17142 3 113002 14248 679 112323 0 0 . 1 . 0 . .
      287.81 3.08 0 1 192 15118 3 113012 14248 679 112333 0 0 . 1 . 0 . .
      287.81 3.08 0 1  47 19452 3 113119 14248 679 112440 0 0 . 1 . 0 . .
      287.81 3.08 0 1  92 17961 3 113084 14248 679 112405 0 0 . 1 . 0 . .
      287.81 3.08 0 1  95 17870 3 113108 14248 679 112429 0 0 . 1 . 0 . .
      287.81 3.08 0 1 199 15021 3 113207 14248 679 112528 0 0 . 1 . 0 . .
      287.81 3.08 0 1 186 15217 3 113161 14248 679 112482 0 0 . 1 . 0 . .

      Comment


      • #4
        Do you have enough return and market return data for each company_id? For example, your event_date starts at 04mar1999 for company_id==1. In that case, you returns data should start at least 60 days earlier of that event date since you are using
        Code:
          
         by company_id: gen estimation_window=1 if dif<-30 & dif>=-60

        Comment


        • #5
          The Princeton code (https://dss.princeton.edu/online_hel...study.html#car) specifies that it is for a 30 day estimation window, have they made an error?

          More pertinently I've noticed that estimation and event window dummies are 0 for all my observations. So it seems as though they haven't incorporated the eventdates that they were suppose to identify. Perhaps there's a problem in the merging portion of the code?

          Comment


          • #6
            No error! Have a closer look at the code. The date interval confirms 30 day estimation window. Here is my suggestion: Take more data then apply the code.

            Comment


            • #7
              Thanks for the suggestion but I have daily data over 20 years and only 243 eventdates so it isn't logical for there not to be enough estimation days. However I think I've realised the source of the problem. Apologies for the snip but I'm unsure of the syntax to choose a portion of the data via dataex, suggestions would be welcome.

              I've noticed that for some reason one Event Date is repeated for all of the observations where "date" has a valid date. After "date" is exhausted my event dates seem to be correct (albeit in US format vs UK in "date"). This in turn has occurred due to the definitions of Merge 2 and Merge 3 categories. So it hasn't mixed my eventdates file with my stockdata file but placed it underneath. How can I get it to merge as I wish?


              Click image for larger version

Name:	Stata.PNG
Views:	1
Size:	21.6 KB
ID:	1452023
              Attached Files

              Comment


              • #8
                If you need help with merging, post a new question. To know more about dataex command, use
                Code:
                help dataex

                Comment


                • #9
                  Great ok thanks for your help.

                  Comment


                  • #10
                    [QUOTE=Toby Jones;n1451729]Hi all,

                    I've conducted an event study using this link https://dss.princeton.edu/online_hel...udy.html#clean, and at the end of it it turns out I do not have enough observations for the final CAR regression.

                    I deviated from the tutorial as my data concerns a single index, whereas it was using the example of a sample of firms, so perhaps that caused the issue. Alternatively I wondered if it was the fact that I wanted to look at only the returns over 1 day (with multiple dates), and so the event window code read as "gen event_window=1 if dif>=-1 & dif<=0", is there any logical problem with this?

                    In terms of what I wish to precisely achieve is to assess if there are CAR regarding macroeconomic events, read as irregular and multiple. The data is for one index. There are multiple events. I have price data, and % change from one price to the next. I only want to measure the change on the day of the event.

                    Edit: I'm using Stata 13.0

                    Disclaimer: I started a similar thread recently asking for assistance but was lacking code to be interrogated. I will link to this thread in that one.

                    Many thanks,

                    Toby




                    Hi all,

                    I am using the same methodology and am trying to figure out how to code the program for multiple events (of the same sort)
                    Following the Princeton code I am stuck at the following line (in cursive).

                    set more off /* this command just keeps stata from pausing after each screen of output */
                    gen predicted_return=.
                    egen id = group(group_id)
                    /* for multiple event dates, use: egen id = group(group_id) */
                    forvalues i=1(1)1

                    The guess is that I have to create clusters for all companies on each event, but am not sure.
                    Has anybody seen this before, and might be able to help?

                    Many thanks,

                    J


                    Comment


                    • #11
                      [QUOTE=Jan van Arkel;n1497113]
                      Originally posted by Toby Jones View Post
                      Hi all,

                      I've conducted an event study using this link https://dss.princeton.edu/online_hel...udy.html#clean, and at the end of it it turns out I do not have enough observations for the final CAR regression.

                      I deviated from the tutorial as my data concerns a single index, whereas it was using the example of a sample of firms, so perhaps that caused the issue. Alternatively I wondered if it was the fact that I wanted to look at only the returns over 1 day (with multiple dates), and so the event window code read as "gen event_window=1 if dif>=-1 & dif<=0", is there any logical problem with this?

                      In terms of what I wish to precisely achieve is to assess if there are CAR regarding macroeconomic events, read as irregular and multiple. The data is for one index. There are multiple events. I have price data, and % change from one price to the next. I only want to measure the change on the day of the event.

                      Edit: I'm using Stata 13.0

                      Disclaimer: I started a similar thread recently asking for assistance but was lacking code to be interrogated. I will link to this thread in that one.

                      Many thanks,

                      Toby




                      Hi all,

                      I am using the same methodology and am trying to figure out how to code the program for multiple events (of the same sort)
                      Following the Princeton code I am stuck at the following line (in cursive).

                      set more off /* this command just keeps stata from pausing after each screen of output */
                      gen predicted_return=.
                      egen id = group(group_id)
                      /* for multiple event dates, use: egen id = group(group_id) */
                      forvalues i=1(1)1

                      The guess is that I have to create clusters for all companies on each event, but am not sure.
                      Has anybody seen this before, and might be able to help?

                      Many thanks,

                      J

                      Hi Jan,

                      I ended up ditching this method and using an easier technique using a one stage regression. It can be found in Seppo Pynnononens 2005 piece On Regression Based event study on page 336. Feel free to PM me if you can't find it/need more info.

                      T

                      Comment


                      • #12
                        Hi. I have a problem in running multi_events in STATA.
                        My problem: I have analyzed 7 companies with 3 events: 30 AUG 2008; 17 DEC 2008 and 19 DEC 2008. I follow this link https://dss.princeton.edu/online_hel...ventstudy.html as same as Toby Jones above and everything go well until this command:
                        egen td=min(target), by(company_id)
                        It makes the regression just analyze the min value as the earliest date: 30 AUG 2008. Could you give me an advice to analyze all 3 date events?

                        Regards

                        Tony Tuan

                        Comment


                        • #13
                          Hey Tony,

                          I have a similar problem. I tried to use the code in #4 https://www.statalist.org/forums/for...s-coding-issue .

                          However, my Macbook gets stuck after the joinby command, whatever I do. Therefore, I do not know how to solve the problem. Since your dataset is way smaller than mine, maybe it'll work out for you.

                          Comment


                          • #14
                            Hi Ryan. Thank you very much for your information. I read the link you send and I see Huw Simpson has same problem that he use the command:
                            egen td=min(target), by(company_id) that will recognize the min value of target, meaning, in the next command gen dif=datenum-td It will show only one event date ( as the min value) not show all event date we need to analyze. In there Mr Robert Picard also give another solution. unfortunately, the command " rangestat" in
                            rangestat (reg) ret2use market_return, interval(group_id 0 0) cannot use in Stata as I tried many times.

                            Comment


                            • #15
                              Hi Tony,

                              I dont know how your data look like but for my data I did the whole process "manually". I have no clue if its right for the later analyses, but its worth a try.

                              use eventdata
                              gen events=1 if Change !=.
                              gen edate=date if events==1
                              format edate %td

                              keep PERMNO date edate
                              drop if edate ==.

                              by PERMNO: gen eventid=_n

                              merge 1:1 PERMNO date using "stock price data"

                              sort PERMNO date
                              by PERMNO: replace eventid=eventid[_n-1] if eventid>=.
                              *therefore I can now identify the specific event to the specific company to calculate cumulative returns for example*

                              gen events=0 if Change !=. (*I define it as day 0)
                              sort PERMNO date
                              xtset PERMNO date
                              by PERMNO: replace events=events[_n-1]+1 if events>=. (*here I set the event window how I need it)
                              by PERMNO: replace events=events[_n+1]-1 if events>=8 (*if your event window is large, this might be a bad idea, but I only need -2 days, so its fine)
                              by PERMNO: replace events=events[_n+1]-1 if events>=8


                              Maybe this idea is completely wrong but as of now it works. At least for my dataset.

                              Comment

                              Working...
                              X