Announcement

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

  • Error r(109) type mismatch when using eventstudy2

    Hi,

    For my finals thesis, I am conducting an event study looking into the abnormal returns received by firms whom contribute to US presidential election candidates. I am attempting to use the eventstudy2 program by Thomas Kaspereit.

    At the moment, I am trying to analyse the 2016 election, looking at firms that contributed to Trump. I have 30 firms which are publicly listed and contributed over $25,000. I am essentially running 30 events each with the same event data - the date of the election.

    This is my code:
    Code:
    use earnings_surprises_trump2
    eventstudy2 security_id date using security_returns_trump3, re(return) model (MA) marketfile(factor_returns_trump_2) mar(market_return) idmar(market_ref) evlb(-1) evwub (3) car1LB(-1) car1UB(3)
    But when I do so, I get the following message:
    Code:
    Generating dateline.. succeeded, preparation of event list.. type mismatch r(109)
    I have three files:

    -earnings_surprises_trump.dta which is stored in memory (Contains: date, earnings_surprise, market_ref, security_id)
    -factor_returns_trump2.dta (Contains: date, market_ref, market_return)
    -security_returns_trump3.dta (Contains: security_id, date, market_ref, return, market_return)

    Any suggestions about the reasons for the error with respect to the string / numeric problem would be most welcome.

    I have been unable to generate png files yet but will continue to work on that.

    Many thanks in advance,

    Kirsty McKnight




  • #2
    Please see attached PDF file with more information about the data files. Apologies I could not create PNG images.
    Attached Files

    Comment


    • #3
      Welcome to Statalist.

      In each of your three datasets, you have date stored as a string variable, which is not a "date variable" in the sense that help eventstudy2 meant. A string is of no use to Stata in calculations involving dates, and when Stata tried to compare a string to a numeric value, it gave the type mismatch error.

      Stata's date and time variables are complicated and there is a lot to learn.

      Before working with dates and times, any Stata user should thoroughly read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

      All Stata manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

      Once you've done the reading, you will understand why you need to follow the instructions for converting your date from a Stata string variable to a numeric Stata Internal Format daily date variable.

      Comment


      • #4
        Dear William,

        Thank you for your reply - that fixed the problem perfectly.

        I have managed to proceed with the package but have encountered another error message. Error r(111): variable_00002F not found.

        Code:
        use earnings_surprises_trump3
        destring, replace
        drop if date ==.
        eventstudy2 security_id date using security_returns_trump6, re(return) model (MA) marketfile(factor_returns_trump4) mar(market_return) idmar(market_ref) evlb(-1) evwub (3) car1LB(-1) car1UB(3)
        Code:
        Generating dateline.. succeeded...
        Preparation of event list... succeeded....
        Preparation of market and/or factor return data....succeeded....
        Merging event dates and stock market data... succeeded....
        Calculating abnormal returns... variable __00002F not found
        r(111)
        Do you have any suggestions why this error has occurred?

        Many thanks again,
        ​​​​​​​Kirsty

        Comment


        • #5
          That message suggests an unanticipated problem deep in the eventstudy2 code: it's a low-level Stata error message.

          I would suggest reviewing the syntax of your command, carefully comparing it to the documentation given by help eventstudy2.

          If that does not lead to a solution of your problem, the output of
          Code:
          net describe eventstudy2, from(http://fmwww.bc.edu/RePEc/bocode/e)
          gives the author's email address for support. Perhaps he can advise you.

          Comment


          • #6
            Thank you for your assistance and time. I contacted Thomas (the author) and have solved the problem. It came from an error in my event date list.
            The program is now working perfectly.

            Comment


            • #7
              Hallo Kirsty,
              I am facing exactly the same issue. Could you please tell me what the error in the vent day list is?

              Comment

              Working...
              X