Announcement

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

  • eventdd error (timevar issue)

    Hi, I've been trying to run eventdd program with my dataset, but i kept getting this error message
    "Lead or lag term not found in the range of the event study plot. Ensure that the indicated timevar() has full coverage for all leads and lags, or attempt accumulating leads and lags using the accum option.
    r(198);"

    My date variable is monthly based. I have tried to convert it into numerical to create a consistent gap of 1 between months. But still doesn't work.
    However, if I collapse the data into a yearly dataset, it works.

    Could anyone please enlighten me? Thank you so much



    numeric_date treatment firsttreat timetotreat date
    627 0 19724 -21 01apr2012
    628 0 19724 -20 01may2012
    .
    .
    .
    646 0 19724 -2 01nov2013
    647 0 19724 -1 01dec2013
    648 1 19724 0 01jan2014
    649 1 19724 1 01feb2014
    650 1 19724 2 01mar2014
    651 1 19724 3 01apr2014
    .
    .
    .
    753 1 19724 107 01oct2022
    754 1 19724 108 01nov2022
    755 1 19724 109 01dec2022

    notes: firsttreat here means 01jan2014

  • #2
    I haven't used eventdd but your variable numeric_date looks fine for your purpose.

    It is difficult to say more because you don't give the code you tried.

    Please back up and read and act on https://www.statalist.org/forums/help#stata which explains about

    * explaining the provenance of community-contributed commands you refer to (here the Stata Journal)

    * showing the exact code you tried

    * giving a data example using dataex that ideally would allow your problem to be reproduced.

    Comment


    • #3
      Hi. Thanks Nick. I revised my post. Hopefully everything is clearer now.


      Here is the code I use:

      eventdd mean_band1 manuf_prop popdens totexpgov hdi i.date, timevar(timetotreat) method(fe)


      clear
      input long adm1 int date float(firsttreat timetotreat) double mean_band1 float(treatment_group manuf_prop popdens totexpgov) double hdi
      68 19084 19724 -21 100.05009080098846 1 5.665826 44.906 14.107292 61.82
      68 19114 19724 -20 99.97513129980159 1 5.665826 44.906 14.107292 61.82
      68 19145 19724 -19 99.89228670656726 1 5.665826 44.906 14.107292 61.82
      68 19175 19724 -18 99.94392190389866 1 5.665826 44.906 14.107292 61.82
      68 19206 19724 -17 99.95176462784475 1 5.665826 44.906 14.107292 61.82
      68 19237 19724 -16 100.04138018337851 1 5.665826 44.906 14.107292 61.82
      68 19267 19724 -15 99.99215869493501 1 5.665826 44.906 14.107292 61.82
      68 19298 19724 -14 100.02691127708847 1 5.665826 44.906 14.107292 61.82
      68 19328 19724 -13 100.01450944478214 1 5.665826 44.906 14.107292 61.82
      68 19359 19724 -12 100.02901119938026 1 5.658553 46.39368 15.533216 62.82
      68 19390 19724 -11 100.09146889624569 1 5.658553 46.39368 15.533216 62.82
      68 19418 19724 -10 100.12547121002316 1 5.658553 46.39368 15.533216 62.82
      68 19449 19724 -9 100.16378265645719 1 5.658553 46.39368 15.533216 62.82
      68 19479 19724 -8 100.17851433219688 1 5.658553 46.39368 15.533216 62.82
      68 19510 19724 -7 100.08818780933937 1 5.658553 46.39368 15.533216 62.82
      68 19540 19724 -6 99.94530334288031 1 5.658553 46.39368 15.533216 62.82
      68 19571 19724 -5 99.99439925515256 1 5.658553 46.39368 15.533216 62.82
      68 19602 19724 -4 99.95359576919779 1 5.658553 46.39368 15.533216 62.82
      68 19632 19724 -3 100.03784311979635 1 5.658553 46.39368 15.533216 62.82
      68 19663 19724 -2 100.03622988873087 1 5.658553 46.39368 15.533216 62.82
      68 19693 19724 -1 100.04482934113788 1 5.658553 46.39368 15.533216 62.82
      68 19724 19724 0 100.01308036470768 1 5.493797 47.90505 17.227724 63.38
      68 19755 19724 1 100.06187373080286 1 5.493797 47.90505 17.227724 63.38
      68 19783 19724 2 100.18920000019045 1 5.493797 47.90505 17.227724 63.38
      68 19814 19724 3 100.14931038375019 1 5.493797 47.90505 17.227724 63.38
      68 19844 19724 4 99.98872941269808 1 5.493797 47.90505 17.227724 63.38
      68 19875 19724 5 99.9371292449146 1 5.493797 47.90505 17.227724 63.38
      68 19905 19724 6 99.96088622921428 1 5.493797 47.90505 17.227724 63.38
      68 19936 19724 7 100.0008707114531 1 5.493797 47.90505 17.227724 63.38
      68 19967 19724 8 99.99999667250363 1 5.493797 47.90505 17.227724 63.38
      68 19997 19724 9 99.96125158500031 1 5.493797 47.90505 17.227724 63.38
      68 20028 19724 10 99.82526502884463 1 5.493797 47.90505 17.227724 63.38
      68 20058 19724 11 100.06295001231841 1 5.493797 47.90505 17.227724 63.38
      68 20089 19724 12 100.12897391521912 1 5.431936 49.43202 16.144207 63.65
      68 20120 19724 13 100.12349876082607 1 5.431936 49.43202 16.144207 63.65
      68 20148 19724 14 100.16972566669277 1 5.431936 49.43202 16.144207 63.65
      68 20179 19724 15 100.07861012335476 1 5.431936 49.43202 16.144207 63.65
      68 20209 19724 16 100.08558923490446 1 5.431936 49.43202 16.144207 63.65
      68 20240 19724 17 99.94666718810515 1 5.431936 49.43202 16.144207 63.65
      68 20270 19724 18 100.00420534722772 1 5.431936 49.43202 16.144207 63.65
      68 20301 19724 19 100.08951900127643 1 5.431936 49.43202 16.144207 63.65
      68 20332 19724 20 100.050876599611 1 5.431936 49.43202 16.144207 63.65
      68 20362 19724 21 100.13869088108217 1 5.431936 49.43202 16.144207 63.65
      68 20393 19724 22 100.06688343842845 1 5.431936 49.43202 16.144207 63.65
      68 20423 19724 23 100.00603863374188 1 5.431936 49.43202 16.144207 63.65
      68 20454 19724 24 99.94797420941964 1 5.776206 50.99498 17.452412 64.02
      68 20485 19724 25 99.98961873785953 1 5.776206 50.99498 17.452412 64.02
      68 20514 19724 26 99.94126364205486 1 5.776206 50.99498 17.452412 64.02
      68 20545 19724 27 100.21025439121085 1 5.776206 50.99498 17.452412 64.02
      68 20575 19724 28 100.09254636991818 1 5.776206 50.99498 17.452412 64.02
      68 20606 19724 29 100.03146270139335 1 5.776206 50.99498 17.452412 64.02
      68 20636 19724 30 100.05029870190627 1 5.776206 50.99498 17.452412 64.02
      68 20667 19724 31 100.02360851379795 1 5.776206 50.99498 17.452412 64.02
      68 20698 19724 32 99.94294787174226 1 5.776206 50.99498 17.452412 64.02
      68 20728 19724 33 100.028297646971 1 5.776206 50.99498 17.452412 64.02
      68 20759 19724 35 99.94429905953672 1 5.776206 50.99498 17.452412 64.02
      68 20789 19724 36 99.99667303875016 1 5.776206 50.99498 17.452412 64.02
      68 20820 19724 37 100.17571082863404 1 5.708469 52.63773 15.238172 64.49
      68 20851 19724 38 100.04239968123449 1 5.708469 52.63773 15.238172 64.49
      68 20879 19724 39 100.34283768249128 1 5.708469 52.63773 15.238172 64.49
      68 20910 19724 40 100.3739096905895 1 5.708469 52.63773 15.238172 64.49
      68 20940 19724 41 100.24710211672823 1 5.708469 52.63773 15.238172 64.49
      68 20971 19724 42 100.14596163854588 1 5.708469 52.63773 15.238172 64.49
      68 21001 19724 43 100.08897288681213 1 5.708469 52.63773 15.238172 64.49
      68 21032 19724 44 100.08872468388054 1 5.708469 52.63773 15.238172 64.49
      68 21063 19724 45 100.23219810553313 1 5.708469 52.63773 15.238172 64.49
      68 21093 19724 46 100.27651426042038 1 5.708469 52.63773 15.238172 64.49
      68 21124 19724 47 100.18105690956217 1 5.708469 52.63773 15.238172 64.49
      68 21154 19724 48 100.28980001985485 1 5.708469 52.63773 15.238172 64.49
      68 21185 19724 49 100.00000237914051 1 5.619113 53.99883 14.234883 65.04
      68 21216 19724 50 100.16549821313613 1 5.619113 53.99883 14.234883 65.04
      165 19084 . . 100.09918074340322 0 .8371002 39.79899 10.848698 64.49
      165 19114 . . 99.97605551072363 0 .8371002 39.79899 10.848698 64.49
      165 19145 . . 99.91030710587602 0 .8371002 39.79899 10.848698 64.49
      165 19175 . . 99.96204035856994 0 .8371002 39.79899 10.848698 64.49
      165 19206 . . 99.97076959211834 0 .8371002 39.79899 10.848698 64.49
      165 19237 . . 100.0449809640047 0 .8371002 39.79899 10.848698 64.49
      165 19267 . . 99.98047055430801 0 .8371002 39.79899 10.848698 64.49
      165 19298 . . 99.9557249379992 0 .8371002 39.79899 10.848698 64.49
      165 19328 . . 99.98677087349814 0 .8371002 39.79899 10.848698 64.49
      165 19359 . . 99.95094516054185 0 .8634581 40.94647 12.37753 65.35
      165 19390 . . 100.03061715452594 0 .8634581 40.94647 12.37753 65.35
      165 19418 . . 100.1321987554187 0 .8634581 40.94647 12.37753 65.35
      165 19449 . . 100.19277529289339 0 .8634581 40.94647 12.37753 65.35
      165 19479 . . 100.13044095012935 0 .8634581 40.94647 12.37753 65.35
      165 19510 . . 100.11675154927043 0 .8634581 40.94647 12.37753 65.35
      165 19540 . . 99.98473906842763 0 .8634581 40.94647 12.37753 65.35
      165 19571 . . 100.03816094074854 0 .8634581 40.94647 12.37753 65.35
      165 19602 . . 99.98825077231602 0 .8634581 40.94647 12.37753 65.35
      165 19632 . . 100.03588806572198 0 .8634581 40.94647 12.37753 65.35
      165 19663 . . 100.03843895742787 0 .8634581 40.94647 12.37753 65.35
      165 19693 . . 100.08732158475495 0 .8634581 40.94647 12.37753 65.35
      165 19724 . . 100.0201557061456 0 .931824 42.10994 11.887823 65.76
      165 19755 . . 100.05980674445004 0 .931824 42.10994 11.887823 65.76
      165 19783 . . 100.06860091982239 0 .931824 42.10994 11.887823 65.76
      165 19814 . . 100.10578501926682 0 .931824 42.10994 11.887823 65.76
      165 19844 . . 100.13386258252943 0 .931824 42.10994 11.887823 65.76
      165 19875 . . 99.95159003915464 0 .931824 42.10994 11.887823 65.76
      165 19905 . . 99.96473245261492 0 .931824 42.10994 11.887823 65.76
      165 19936 . . 100.00201115735811 0 .931824 42.10994 11.887823 65.76
      end
      format %td date
      label values adm1 adm1
      label variable timetotreat "in term of month"
      label variable firsttreat "first treatment"
      label variable mean_band1 "outcome variable"
      label variable treatment_group "=1 treatment group"
      label variable adm1 "ID variable"
      label variable date "time variable"
      label variable manuf_prop "control variable 1"
      label variable popdens "control variable 2"
      label variable totexpgov "control variable 3"
      label variable hdi "control variable 4"

      Comment


      • #4
        Thanks for the detail. Question is now in better shape for anyone who uses this command.

        Comment


        • #5
          I'm not sure if this is your true data, but it seems there is only a single unit and single control variable, and time periods are quite unbalanced, so it is likely that panel event studies are not well suited to this setting. Nevertheless, if you wish to use eventdd you can do so. Given significant misbalance in the panel, you'd need to indicate some limit of lags and leads which line up with the periods identified. For example, based on the data you have above, if I do the following, no problems are observed.
          Code:
          xtset adm1 date
          eventdd mean_band1 manuf_prop popdens totexpgov hdi i.date, timevar(timetotreat) method(fe) leads(15) lags(10) accum
          Best wishes,
          Damian

          Comment


          • #6
            Thank you so much Nick, Damian for the response. What Damian said is correct, the data isn't balanced. I've tried to simulate with different strategies and it worked. Thanks again!

            Comment


            • #7
              I encountered the same problem, then I found that's because my timevar() had no missing value. maybe you can check your definition of timevar()

              Comment

              Working...
              X