Announcement

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

  • Unstable Results in Stata eventstudy2 Command

    When using the eventstudy2 command by Stata 18.0, I have faced with two main problems, even when using the same raw dataset without any modifications:

    1. Inconsistent number of identified events

    When running the command repeatedly with a large sample size, some stock events are occasionally misclassified into the diagnosticsfile.dta as problematic events, and the most common reason is "Event with event date off the dateline", leading to fluctuating counts of identified events. As is shown in Table 1,
    • 1st attempt: 145 events identified
    • 2nd attempts:147 events identified
    • 3rd attempts: 149 events identified (full identification, all valid events recognized), it seems that the only way to achieve full identification is to run the command repeatedly for trial (some times it takes many times)
    Notably, this issue is intermittent — rerunning the command multiple times may temporarily resolve it, but it reoccurs unpredictably.

    2. Inconsistent CAR/AARE results with the same number of events

    Even when the command consistently identifies 149 events (full identification), the results (e.g., AARE and CAR) vary across runs. As is shown in Table 1, the result between the 3rd and 4th attempt is different, even though all 149 events have been identified.

    Table 1:
      1st Attempt 2nd Attempt 3rd Attempt 4th Attempt
    t NoFirms AARE NoFirms AARE NoFirms AARE NoFirms AARE
    -10 145 -0.013% 147 0.136% 149 0.060% 149 -0.137%
    -9 145 -0.245% 147 -0.101% 149 -0.079% 149 -0.054%
    -8 145 0.035% 147 -0.316% 149 -0.046% 149 -0.032%
    -7 145 -0.161% 147 -0.003% 149 -0.237% 149 -0.068%
    -6 145 -0.135% 147 0.013% 149 -0.057% 149 -0.184%
    -5 145 0.017% 147 -0.282% 149 -0.108% 149 -0.154%
    -4 145 -0.274% 147 -0.061% 149 -0.302% 149 -0.179%
    -3 145 -0.077% 147 0.058% 149 0.110% 149 0.202%
    -2 145 -0.046% 147 -0.249% 149 0.096% 149 -0.281%
    -1 145 -0.674% 147 -0.276% 149 -0.432% 149 -0.280%
    0 145 -0.352% 147 -0.640% 149 -0.702% 149 -0.817%
    1 145 -0.591% 147 -0.429% 149 -0.369% 149 -0.324%
    2 145 -0.376% 147 -0.653% 149 -0.686% 149 -0.518%
    3 145 -0.126% 147 -0.136% 149 -0.315% 149 -0.278%
    4 145 -0.048% 147 -0.176% 149 -0.022% 149 -0.059%
    5 145 -0.234% 147 -0.225% 149 0.001% 149 -0.216%
    6 145 -0.072% 147 0.044% 149 -0.258% 149 -0.012%
    7 145 -0.530% 147 -0.491% 149 -0.363% 149 -0.636%
    8 145 0.121% 147 -0.028% 149 -0.176% 149 0.098%
    9 145 -0.162% 147 -0.197% 149 -0.111% 149 -0.202%
    10 145 -0.110% 147 -0.337% 149 -0.173% 149 -0.167%
    CAR[-10,10]   -4.053%   -4.349%   -4.168%   -4.295%

    You can try the data sample provided below, and the syntax is:
    Code:
    use eventdays.dta, clear
    
    eventstudy2 stkcd date using stk_ret, ret(ret) evwlb(-10) evwub(10) ///
    mod(FM) marketfile(index_ret) mar(ret_index) idmar(indexcd) ///
    car1LB(-1) car1UB(1) car5LB(-5) car5UB(5) car10LB(-10) car10UB(10) ///
    eswlb(-150) eswub(-20) arfillevent replace
    Attached Files
    Last edited by Ray Hou; 23 Jan 2026, 19:48.

  • #2
    Dear Ray Hou,

    Thank you very much for posting this interesting case.

    The randomness across runs arises from how Stata handles tied observations (duplicates). When sorting on x and y with duplicate values in both variables, each sort may produce different outcomes because there is no single "correct" way to break ties. By programming convention, such sorts are therefore allowed to be random. Of course, the outcome is only pseudo-random in the sense that it is deterministic given a specific seed.

    Within eventstudy2, sorting is performed internally, particularly by the command nearmrg.ado, which eventstudy2 calls. It is documented elsewhere that nearmrg can yield unstable outcomes because its sorts are not "stable." For this reason, eventstudy2 was later updated to include its own version of nearmrg with stable sorting. However, you are using a very old version of eventstudy2, which does not incorporate this update.

    I have redone your analysis using the most recent version of eventstudy2 and can confirm that the randomness across runs disappears. Please note that the latest version requires Stata 19, and the syntax must be updated as follows:

    eventstudy2 stkcd date using stk_ret, ret(ret) evwlb(-10) evwub(10) ///
    mod(FM) marketfile(index_ret) mar(ret_index) idmar(indexcd) ///
    car1lb(-1) car1ub(1) car5lb(-5) car5ub(5) car10lb(-10) car10ub(10) ///
    eswlb(-150) eswub(-20) arfillevent replace

    If you are using Stata 18 or earlier, please refer to the following post:

    https://www.statalist.org/forums/for...t-with-stata17

    All the best
    Thomas Kaspereit

    Comment


    • #3
      Dear Prof. Kaspereit,

      1. Using Stata 18

      From my understanding, setting a seed can resolve this issue. Yet after I have set the seed, it seems that the problem 1 and 2 mentioned in the initial post still persists (using Stata 18 and the eventstudy2 version provided by Emilio Chen). I wonder if I made a mistake in the way I set the seed. My syntax is,

      Code:
      use eventdays.dta, clear
      
      set seed 223
      eventstudy2 stkcd date using stk_ret, ret(ret) evwlb(-10) evwub(10) ///
      mod(FM) marketfile(index_ret) mar(ret_index) idmar(indexcd) ///
      car1LB(-1) car1UB(1) car5LB(-5) car5UB(5) car10LB(-10) car10UB(10) ///
      eswlb(-150) eswub(-20) arfillevent replace
      2. Using StataNow MP/19.5

      In addition, I have also used Stata 19 with the latest version of eventstudy2, but it returned an error message saying "invalid name" (the same result with Emilio Chen's post). What's more, the same error occurred when I ran the test the example (earnings_surprises.dta) provided in the help eventstudy2 documentation, and the the lowercase option car1lb is not allowed. So far, I am kind of lost.
      Click image for larger version

Name:	Snipaste_2026-01-25_20-40-50.jpg
Views:	1
Size:	289.8 KB
ID:	1784519


      Sincerely,
      Ray HOU

      Comment


      • #4
        Dear Ray Hou,

        Thank you for your effort in addressing this issue.

        Could you please confirm whether the update has been applied successfully? Specifically, can you verify that the evenstudy2.ado file in your personal folder is the latest version and that it has been properly loaded? Restarting Stata may help ensure that the updated file is in use.

        Best regards,
        Thomas Kaspereit

        Comment


        • #5
          Dear Prof. Kaspereit,

          Thank you, Professor, for your patience and continuous contributions to the update of eventstudy2. I have finally identified the root cause—it all comes down to whether Stata has been updated to the latest version.

          The Stata 19 I initially downloaded was the original version released on April 8, 2025, while the latest version of eventstudy2 was updated on September 24, 2025. That is why even though I was using Stata 19, I still could not get it to run. After I ran the update all command to upgrade Stata to the version released after September 24, 2025, the results became stable.

          Thank you so much for your patient responses!

          Sincerely,
          Ray Hou
          Last edited by Ray Hou; 25 Jan 2026, 09:57.

          Comment


          • #6
            Hi Prof, I have tried running eventstudy2 but it keeps giving me invalid file name

            Comment

            Working...
            X