Announcement

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

  • oscillating results in event study

    Hi everyone,

    I am new at stata and event study and I hope you can help me with me. I followed the event study of this website.
    What I did:
    I have a excel list with different company ids which i merged with the corresponding stock data. (started with one stock data file and appended the rest)
    Now I am pretty much followed the code from princeton.edu.
    What I do want now is to collapse the data by each difference from the event window and plot the mean of the CAR for each dif. (dif = date - eventdate //date = stock data date

    I used following code:
    sort dif
    collapse (mean) new_CAR = CAR


    Now appears my problem. The results are going up and down on a non regular basis after, if I have more than one event (see example). It doesn't matter if I keep just one company or a different companies. Does anyone have an idea what could be the problem?

    Thank you so much


    Click image for larger version

Name:	example for statalist.JPG
Views:	1
Size:	27.4 KB
ID:	1400926


  • #2
    I used following code:
    sort dif
    collapse (mean) new_CAR = CAR
    Um, no, you didn't. Or, if you did, you didn't get that graph from the results. That code would reduce your entire data set to a single observation containing only one variable, new_CAR and its unique value would be the mean of all the original CAR values in the data set. There would be no possibility of graphing it this way.

    More to the point, I can't figure out from your description what you actually did do, so I can't advise you on how to change it. So please read the FAQ for excellent advice about how to post clear questions that are likely to draw a timely, helpful response. In particular, unless your data set is so simple it can be completely described in a few words, show a data example using the -dataex- command. Use code delimiters to show the exact code you tried and the exact output you got from Stata. And exact means, literally, exact: don't change it in any way.

    If you provide enough information, it is likely someone will be able to help you solve your problem.

    Comment


    • #3
      Thank you for your advice.

      My event data set contains around 9000 tweets (date %td format). Around 500 tweets are related to a specific company id (permno), which I want to merge with the stock data (contains return, date, return on the S&P500). The tweets are classified into different moods. I redated the tweets in case the tweets was during a weekend or non-trading day to the next trading day.
      I am using Stata 14.
      My question: I still get ups and downs in the calculation of the CAR (an example how it looks like you can see in my first post). What seems to me wrong.

      The code:
      --------------------------------------------------
      use "C:\excellist"
      //Filter Mood
      keep if Mood=="-"
      drop if company_id ==0
      drop if company_id==.
      save "C:\eventdates", replace
      by permno: generate eventcount=_N
      by permno: keep if _n==1
      sort permno
      keep permno eventcount
      save "C:\eventcount", replace

      use "C:\company1.dta"
      append using "C:\company2.dta"
      /*....*/
      append using "C:\company30.dta"

      sort permno
      merge permno using "C:\eventcount"
      tab _merge
      keep if _merge==3
      drop _merge
      expand eventcount
      drop eventcount
      sort permno date
      by permno date: gen set=_n
      sort permno set
      save "C:\stockdata2", replace
      use "C:\eventdates", clear
      by permno: gen set =_n
      sort permno set
      save "C:\eventdates2", replace
      use "C:\stockdata2.dta", clear
      merge permno set using "C:\eventdates2"
      tab _merge
      list permno if _merge==2
      keep if _merge==3
      drop _merge
      egen group_id = group(permno set)
      gen dif = date - eventdate
      sort permno
      by permno: gen event_window = 1 if (dif>=-2 & dif<=2)
      egen count_event_obs = count(event_window), by(permno)
      by permno: gen estimation_window = 1 if (dif<-30 & dif>=-60)
      egen count_est_obs = count(estimation_window), by(permno)
      replace event_window = 0 if event_window ==.
      replace estimation_window = 0 if estimation_window==.
      save "C:\eventdateSAVE", replace
      tab permno if count_event_obs<5
      tab permno if count_est_obs<30
      drop if count_event_obs<5
      drop if count_est_obs<30
      gen predicted_return=.
      egen id = group(group_id)
      egen max_id = max(id)

      forvalues i=1(1)162 {
      l id permno if (id==`i'&dif==0)
      reg ret sprtrn if (id==`i'&estimation_window==1)
      predict p if id==`i'
      replace predicted_return = p if (id==`i' & event_window==1)
      drop p
      }
      sort id date
      gen abnormal_return = ret-predicted_return if event_window==1
      by id: gen cumulative_abnormal_return = sum(abnormal_return)

      sort dif
      collapse (mean) neutral_abn_ret_mean = abnormal_return (mean) neutral_cabn_ret_mean = cumulative_abnormal_return, by(dif)

      drop if dif<-50
      drop if dif>50
      twoway (line neutral_cabn_ret_mean dif)
      --------------------------------------------------

      this output contains the data after for loop and the calculation of the abnormal return and the CAR.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double(permno date ret sprtrn) float set str1 Mood float(eventdate group_id dif event_window count_event_obs estimation_window count_est_obs predicted_return id max_id abnormal_return cumulative_abnormal_return)
      14593 20453   -.019194908440113068   -.009411833 1 "-" 20503 5 -50 0 6 1 38            . 1 162           .           0
      14593 20457   .0008549908525310457    -.01530378 1 "-" 20503 5 -46 0 6 1 38            . 1 162           .           0
      14593 20458   -.025059320032596588    .002012262 1 "-" 20503 5 -45 0 6 1 38            . 1 162           .           0
      14593 20459    -.01956968382000923    -.01311542 1 "-" 20503 5 -44 0 6 1 38            . 1 162           .           0
      14593 20460    -.04220457002520561    -.02370042 1 "-" 20503 5 -43 0 6 1 38            . 1 162           .           0
      14593 20461    .005287736188620329    -.01083841 1 "-" 20503 5 -42 0 6 1 38            . 1 162           .           0
      14593 20464     .01619224064052105   .0008532645 1 "-" 20503 5 -39 0 6 1 38            . 1 162           .           0
      14593 20465    .014513349160552025    .007802794 1 "-" 20503 5 -38 0 6 1 38            . 1 162           .           0
      14593 20466    -.02571028098464012    -.02496544 1 "-" 20503 5 -37 0 6 1 38            . 1 162           .           0
      14593 20467    .021870801225304604     .01669594 1 "-" 20503 5 -36 0 6 1 38            . 1 162           .           0
      14593 20468   -.024015268310904503    -.02159909 1 "-" 20503 5 -35 0 6 1 38            . 1 162           .           0
      14593 20472   -.004838809836655855   .0005318216 1 "-" 20503 5 -31 0 6 1 38            . 1 162           .           0
      14593 20473   .0013448918471112847    -.01169385 1 "-" 20503 5 -30 0 6 0 38            . 1 162           .           0
      14593 20474   -.005062484182417393     .00519542 1 "-" 20503 5 -29 0 6 0 38            . 1 162           .           0
      14593 20475    .053167134523391724     .02028368 1 "-" 20503 5 -28 0 6 0 38            . 1 162           .           0
      14593 20478   -.019522733986377716    -.01563795 1 "-" 20503 5 -25 0 6 0 38            . 1 162           .           0
      14593 20479    .005530927330255508     .01414431 1 "-" 20503 5 -24 0 6 0 38            . 1 162           .           0
      14593 20480    -.06570656597614288    -.01086346 1 "-" 20503 5 -23 0 6 0 38            . 1 162           .           0
      14593 20481    .007171892561018467    .005528559 1 "-" 20503 5 -22 0 6 0 38            . 1 162           .           0
      14593 20482     .03454139828681946     .02476021 1 "-" 20503 5 -21 0 6 0 38            . 1 162           .           0
      14593 20485   -.009348634630441666  -.0004432441 1 "-" 20503 5 -18 0 6 0 38            . 1 162           .           0
      14593 20486     -.0202218908816576     -.0187431 1 "-" 20503 5 -17 0 6 0 38            . 1 162           .           0
      14593 20487    .019792497158050537    .004992039 1 "-" 20503 5 -16 0 6 0 38            . 1 162           .           0
      14593 20488    .007991696707904339    .001526773 1 "-" 20503 5 -15 0 6 0 38            . 1 162           .           0
      14593 20489   -.026708094403147697     -.0184813 1 "-" 20503 5 -14 0 6 0 38            . 1 162           .           0
      14593 20492    .010529733262956142    -.01415388 1 "-" 20503 5 -11 0 6 0 38            . 1 162           .           0
      14593 20493 -.00021054911485407501  -.0006636309 1 "-" 20503 5 -10 0 6 0 38            . 1 162           .           0
      14593 20494   -.007579758297652006  -.0001889635 1 "-" 20503 5  -9 0 6 0 38            . 1 162           .           0
      14593 20495   -.006046459078788757    -.01230115 1 "-" 20503 5  -8 0 6 0 38            . 1 162           .           0
      14593 20496   .0030949937645345926     .01951801 1 "-" 20503 5  -7 0 6 0 38            . 1 162           .           0
      14593 20500    .028194505721330643     .01651669 1 "-" 20503 5  -3 0 6 0 38            . 1 162           .           0
      14593 20501     .01531460415571928     .01648044 1 "-" 20503 5  -2 1 6 0 38   .017617123 1 162 -.002302519 -.002302519
      14593 20502   -.018956385552883148   -.004665718 1 "-" 20503 5  -1 1 6 0 38  -.006260598 1 162 -.012695787 -.014998307
      14593 20503  -.0022854895796626806 -.00002607113 1 "-" 20503 5   0 1 6 0 38 -.0010216227 1 162 -.001263867 -.016262174
      14593 20506    .008746317587792873     .01445421 1 "-" 20503 5   3 0 6 0 38            . 1 162           . -.016262174
      14593 20507   -.022605232894420624    -.01245438 1 "-" 20503 5   4 0 6 0 38            . 1 162           . -.016262174
      14593 20508    .014890654012560844    .004439772 1 "-" 20503 5   5 0 6 0 38            . 1 162           . -.016262174
      14593 20509   .0068678841926157475     .01134833 1 "-" 20503 5   6 0 6 0 38            . 1 162           . -.016262174
      14593 20510   .0015502431197091937   -.001870164 1 "-" 20503 5   7 0 6 0 38            . 1 162           . -.016262174
      14593 20513    -.00227016001008451   -.008120941 1 "-" 20503 5  10 0 6 0 38            . 1 162           . -.016262174
      14593 20514      .0397145114839077     .02386879 1 "-" 20503 5  11 0 6 0 38            . 1 162           . -.016262174
      14593 20515   .0021884136367589235    .004094321 1 "-" 20503 5  12 0 6 0 38            . 1 162           . -.016262174
      14593 20516    .007444168906658888    .003498704 1 "-" 20503 5  13 0 6 0 38            . 1 162           . -.016262174
      14593 20517    .014876868575811386    .003305909 1 "-" 20503 5  14 0 6 0 38            . 1 162           . -.016262174
      14593 20520   -.011066881008446217   .0008850044 1 "-" 20503 5  17 0 6 0 38            . 1 162           . -.016262174
      14593 20521   -.008245842531323433    -.01124011 1 "-" 20503 5  18 0 6 0 38            . 1 162           . -.016262174
      14593 20522   .0008908637682907283    .005052393 1 "-" 20503 5  19 0 6 0 38            . 1 162           . -.016262174
      14593 20523   .0004944167449139059   .0001558368 1 "-" 20503 5  20 0 6 0 38            . 1 162           . -.016262174
      14593 20524    .010773984715342522      .0163955 1 "-" 20503 5  21 0 6 0 38            . 1 162           . -.016262174
      14593 20527   .0025424847844988108   -.001261009 1 "-" 20503 5  24 0 6 0 38            . 1 162           . -.016262174
      14593 20528     .02009369060397148   -.001836961 1 "-" 20503 5  25 0 6 0 38            . 1 162           . -.016262174
      14593 20529     .01329125463962555    .005600393 1 "-" 20503 5  26 0 6 0 38            . 1 162           . -.016262174
      14593 20530   -.001604210352525115    .006595239 1 "-" 20503 5  27 0 6 0 38            . 1 162           . -.016262174
      14593 20531   .0011341692879796028    .004405588 1 "-" 20503 5  28 0 6 0 38            . 1 162           . -.016262174
      14593 20534 -.00009435901301912963   .0009855678 1 "-" 20503 5  31 0 6 0 38            . 1 162           . -.016262174
      14593 20535    .007647979538887739   -.000877364 1 "-" 20503 5  32 0 6 0 38            . 1 162           . -.016262174
      14593 20536   -.005528522655367851   -.006385989 1 "-" 20503 5  33 0 6 0 38            . 1 162           . -.016262174
      14593 20537   -.004334298428148031  -.0003780607 1 "-" 20503 5  34 0 6 0 38            . 1 162           . -.016262174
      14593 20541   -.004542402923107147   .0005452027 1 "-" 20503 5  38 0 6 0 38            . 1 162           . -.016262174
      14593 20542    .023671431466937065    .008816672 1 "-" 20503 5  39 0 6 0 38            . 1 162           . -.016262174
      14593 20543    .017459113150835037    .004350344 1 "-" 20503 5  40 0 6 0 38            . 1 162           . -.016262174
      14593 20544  -.0052026258781552315   -.002039778 1 "-" 20503 5  41 0 6 0 38            . 1 162           . -.016262174
      14593 20545    .009175153449177742    .006330896 1 "-" 20503 5  42 0 6 0 38            . 1 162           . -.016262174
      14593 20548    .010273706167936325   -.003208252 1 "-" 20503 5  45 0 6 0 38            . 1 162           . -.016262174
      14593 20549   -.011789103038609028    -.01014457 1 "-" 20503 5  46 0 6 0 38            . 1 162           . -.016262174
      14593 20550    .010472648777067661     .01050768 1 "-" 20503 5  47 0 6 0 38            . 1 162           . -.016262174
      14593 20551   -.021809644997119904    -.01197585 1 "-" 20503 5  48 0 6 0 38            . 1 162           . -.016262174
      14593 20552   .0011056085349991918    .002786607 1 "-" 20503 5  49 0 6 0 38            . 1 162           . -.016262174
      14593 20453   -.019194908440113068   -.009411833 2 "-" 20503 6 -50 0 6 1 38            . 2 162           .           0
      14593 20457   .0008549908525310457    -.01530378 2 "-" 20503 6 -46 0 6 1 38            . 2 162           .           0
      14593 20458   -.025059320032596588    .002012262 2 "-" 20503 6 -45 0 6 1 38            . 2 162           .           0
      14593 20459    -.01956968382000923    -.01311542 2 "-" 20503 6 -44 0 6 1 38            . 2 162           .           0
      14593 20460    -.04220457002520561    -.02370042 2 "-" 20503 6 -43 0 6 1 38            . 2 162           .           0
      14593 20461    .005287736188620329    -.01083841 2 "-" 20503 6 -42 0 6 1 38            . 2 162           .           0
      14593 20464     .01619224064052105   .0008532645 2 "-" 20503 6 -39 0 6 1 38            . 2 162           .           0
      14593 20465    .014513349160552025    .007802794 2 "-" 20503 6 -38 0 6 1 38            . 2 162           .           0
      14593 20466    -.02571028098464012    -.02496544 2 "-" 20503 6 -37 0 6 1 38            . 2 162           .           0
      14593 20467    .021870801225304604     .01669594 2 "-" 20503 6 -36 0 6 1 38            . 2 162           .           0
      14593 20468   -.024015268310904503    -.02159909 2 "-" 20503 6 -35 0 6 1 38            . 2 162           .           0
      14593 20472   -.004838809836655855   .0005318216 2 "-" 20503 6 -31 0 6 1 38            . 2 162           .           0
      14593 20473   .0013448918471112847    -.01169385 2 "-" 20503 6 -30 0 6 0 38            . 2 162           .           0
      14593 20474   -.005062484182417393     .00519542 2 "-" 20503 6 -29 0 6 0 38            . 2 162           .           0
      14593 20475    .053167134523391724     .02028368 2 "-" 20503 6 -28 0 6 0 38            . 2 162           .           0
      14593 20478   -.019522733986377716    -.01563795 2 "-" 20503 6 -25 0 6 0 38            . 2 162           .           0
      14593 20479    .005530927330255508     .01414431 2 "-" 20503 6 -24 0 6 0 38            . 2 162           .           0
      14593 20480    -.06570656597614288    -.01086346 2 "-" 20503 6 -23 0 6 0 38            . 2 162           .           0
      14593 20481    .007171892561018467    .005528559 2 "-" 20503 6 -22 0 6 0 38            . 2 162           .           0
      14593 20482     .03454139828681946     .02476021 2 "-" 20503 6 -21 0 6 0 38            . 2 162           .           0
      14593 20485   -.009348634630441666  -.0004432441 2 "-" 20503 6 -18 0 6 0 38            . 2 162           .           0
      14593 20486     -.0202218908816576     -.0187431 2 "-" 20503 6 -17 0 6 0 38            . 2 162           .           0
      14593 20487    .019792497158050537    .004992039 2 "-" 20503 6 -16 0 6 0 38            . 2 162           .           0
      14593 20488    .007991696707904339    .001526773 2 "-" 20503 6 -15 0 6 0 38            . 2 162           .           0
      14593 20489   -.026708094403147697     -.0184813 2 "-" 20503 6 -14 0 6 0 38            . 2 162           .           0
      14593 20492    .010529733262956142    -.01415388 2 "-" 20503 6 -11 0 6 0 38            . 2 162           .           0
      14593 20493 -.00021054911485407501  -.0006636309 2 "-" 20503 6 -10 0 6 0 38            . 2 162           .           0
      14593 20494   -.007579758297652006  -.0001889635 2 "-" 20503 6  -9 0 6 0 38            . 2 162           .           0
      14593 20495   -.006046459078788757    -.01230115 2 "-" 20503 6  -8 0 6 0 38            . 2 162           .           0
      14593 20496   .0030949937645345926     .01951801 2 "-" 20503 6  -7 0 6 0 38            . 2 162           .           0
      14593 20500    .028194505721330643     .01651669 2 "-" 20503 6  -3 0 6 0 38            . 2 162           .           0
      14593 20501     .01531460415571928     .01648044 2 "-" 20503 6  -2 1 6 0 38   .017617123 2 162 -.002302519 -.002302519
      end
      format %d date
      format %td eventdate
      Any help would be very gratefully received
      Markus

      Comment


      • #4
        Thank you for posting your code and the data following the calculations of cumulative abnormal return. I am unable to reproduce your problem. When I run it, I get a graph that is flat at 0 from dif = -50 to 0, then drops almost vertically at 0, and is then flat at about -.016 out to dif = 50.

        My only thought is this: the example data you send contains only one permno. If your full data set contains multiple permnos, when you run
        Code:
        collapse (mean) neutral_abn_ret_mean = abnormal_return (mean) neutral_cabn_ret_mean = cumulative_abnormal_return, by(dif)
        you are averaging together the abnormal returns from different firms at the same time points. Assuming that different firms respond differently to these events, that could explain why you are getting a graph that jumps around. If you have multiple permno's in your real data, you probably want to change -by(dif)- to -by(dif permno)- and then you want to graph the different permno's results separately.

        Comment

        Working...
        X