Announcement

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

  • Error r(459) while applying eventstudy2

    Hi Guys,

    for my master thesis I need to conduct an Event Study. I investigate if there is a connection between announcements related to movie adaptions of novels and the return of the movie studio which is doing the adaption. As I am new to Stata, I was really thankful for the eventstudy2 Programm by Thomas Kaspereit.

    I am trying to apply it with the following formula:

    eventstudy2 security_id date using securityreturnsfile,returns(security_returns) model(MA)marketfile(marketfile) marketreturns(market_returns) idmarket(market_id) evwlb(-1) evwub(1) eswlb(-120) eswub(-2) aarfile(Averageabnormalreturns)

    But when I do so, I get the following error message:

    variables date market_id do not uniquely identify observations in the using data r(459);

    I have three files:

    -eventlist.dta which is stored in memory (Contains: event_id;security_id;date)
    -marketfile.dta (Contains:market_id;date;market_returns)
    -securityreturnsfile.dta (Contains:security_id;market_id;date;price;securit y_returns)

    The files are not equally sized. Securityreturnsfile is the biggest file, because it includes the return data of 7 Companies for the time from 2007-2016, while the marketfile also contains return data from 2007-2016, but only for the SP500. The eventlist contains 437 Columns with events. I am not sure if that plays a role, since I know, that this kind of error typically occurs while merging two files.

    I really researched a lot, but I could not find any solution for my problem.

    See attached screenshots of these files.

    I hope I did not forget any information which is needed to find a solution. I also hope I am not stealing your time with a really simple problem.

    Thanks in advance,

    Alexander Kolb
    securityreturnsfile-screenshot.tiffmarketfile screenshot.tiffeventlist screenshot.tiff

  • #2
    Please do read and act on

    http://www.statalist.org/forums/help#stata 12,1 12.4 12.5

    Comment


    • #3
      Thanks for the advice Nick. I now tried to follow this rules and additionally I exctracted some example data with dataex (I am confused why date is not displayed in Format DMY when using dataex:

      Securityreturnfiles

      Code:
      input byte security_id int(market_id date) str17 Price double security_returns
      15 500 17076 "20.279994"                     .
      15 500 17077 "20.260003" -.0009857497985451785
      15 500 17078 "20.310004"   .002467966070883513
      15 500 17079 "20.399998"   .004431018329686238
      15 500 17080 "20.449999"  .0024510296520616416
      15 500 17083 "20.700001"   .012225037272618061
      15 500 17084 "20.950003"   .012077390720898926
      15 500 17085 "20.989997"  .0019090212063454161
      15 500 17086 "21.150005"   .007623059688860426
      15 500 17087 "21.389999"   .011347231359992556
      15 500 17090 "21.710004"   .014960496258087805
      15 500 17091 "21.640001"  -.003224458180661773
      15 500 17092 "21.729996"    .00415873363406953
      15 500 17093 "21.77"      .0018409575409033534
      15 500 17094 "21.720001" -.0022966926963711386
      15 500 17097 "21.619999"  -.004604143434431699
      15 500 17098 "21.529994"  -.004163043670816148
      15 500 17099 "21.610005"  .0037162574220876467
      15 500 17100 "21.640001"  .0013880607616703732
      15 500 17101 "21.660004"  .0009243530071925183
      end
      format %tdnn/dd/CCYY date
      Marketfile:

      Code:
      input int(market_id date) double market_returns
      500 17076                     .
      500 17077   .002095693832562754
      500 17078   .012060449423890642
      500 17079  .0022367205670265435
      500 17080 -.0026824944043040456
      500 17083  .0007928837846738941
      500 17084  .0020434527790284536
      500 17085  -.002563943851270394
      500 17086    .00954109816475706
      500 17087   .002047239266877385
      500 17090  .0025190492322865357
      500 17091   -.00365945231333344
      500 17092   .001282944127514195
      500 17093  .0008492546188216433
      500 17094  .0011997535017779124
      500 17097   .006152304652678119
      500 17098  .0002614232144570066
      500 17099   .003513893030558407
      500 17100   .004963019739207669
      500 17101  -.008451630123442681
      end
      format %tdnn/dd/CCYY date
      Eventlist:

      Code:
      input byte(event_id security_id) long date
      1 12 17443
      1 12 17518
      1 12 17518
      1 13 17800
      1 14 17821
      1 15 17870
      1 12 17927
      1 16 17927
      1 16 18007
      1 18 18092
      1 15 18211
      1 16 18246
      1 14 18238
      1 14 18304
      1 13 18346
      1 12 18431
      1 17 18659
      1 15 18693
      1 17 18704
      1 18 18709
      end
      format %tdnn/dd/CCYY date
      See attached screenshots of these files.

      Eventlist:

      Click image for larger version

Name:	eventlist screenshot.png
Views:	1
Size:	33.2 KB
ID:	1365703


      securityreturnsfile:

      Click image for larger version

Name:	securityreturnsfile-screenshot.png
Views:	1
Size:	86.1 KB
ID:	1365704


      marketfile:

      Click image for larger version

Name:	marketfile screenshot.png
Views:	1
Size:	25.2 KB
ID:	1365705


      I hope I did not forget any information which is needed to find a solution. I also hope I am not stealing your time with a really simple problem.

      Thanks in advance,

      Alexander Kolb

      Comment


      • #4
        Thanks for this. I don't see any source given for the user-written program eventstudy2

        I note that price is a string variable.. You don't seem to use it, but that looks wrong.

        See also http://www.stata.com/support/faqs/da...d-time-values/ and

        Code:
        help duplicates 
        duplicates list  date market_id  
        * etc.

        Comment


        • #5
          Thanks Nick.

          The Source for eventstudy2 would be: https://ideas.repec.org/c/boc/bocode/s458086.html .

          Thank you very much for the suggestion with the duplicates code. That was the error. In my marketfile, after the last date there were about 100 rows filled with ".", that caused the error and after deleting this, it finally worked.

          Thanks for your fast help!

          Comment

          Working...
          X