Announcement

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

  • stata evenstudy2 package

    I use stata SE 14.2 version to do event study analysis. I'm using eventstudy2 package, but always some problem comes up from the command. is there anyone who can explain me in detail?
    Thank you

  • #2
    Please read this section first and learn how to make a good post before you make a post. Welcome to the Statalist.
    Roman

    Comment


    • #3
      🤣🤣🤣🤣🤣🤣🤣 Welcome to Statalist. I'd like a little description of the problem, the specific errors Stata issued, as well as a small example of your dataset using the dataex command and the exact code you used.

      As is, there could literally be one of 100 issues here.

      Comment


      • #4
        I am really sorry because different issues are always coming. I have already followed the instructions. I have installed eventstudy2, moremata, nearmrg, distinct, _gprod, rmse, parallel. Make the data in 3 files. Change the date format.
        Now the issue is "variables date __000005 do not uniquely identify observations in the using data"

        this is my command:

        eventstudy2 firmid date using securityreturn, returns(return) model(FM) marketfile(marketfile) marketreturns(marketreturn) idmarket(securityid) factor1(factor1) factor2(factor2) evwlb(-1) evwub(1) eswlb(-150) eswub(-36) delweekend parallel

        Here is my data:

        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input byte firmid int date double stockreturn
        1 18687     .002
        1 18688  .002994
        1 18689  .014925
        1 18690  .023529
        1 18693        0
        1 18694 -.011494
        1 18695  .002907
        1 18696 -.028986
        1 18697  .002985
        1 18700 -.034722
        1 18701 -.012333
        1 18702 -.006243
        1 18703        0
        1 18704  .006283
        1 18707 -.010406
        1 18708 -.023134
        1 18709  .001076
        1 18710  .005376
        1 18711  .018182
        1 18714  .022059
        1 18715  .028777
        1 18716 -.008991
        1 18717  .171371
        1 18718 -.039587
        1 18721 -.031362
        1 18722  .034228
        1 18723  -.00805
        1 18724  .027953
        1 18725 -.027193
        1 18728 -.045987
        1 18729 -.024575
        1 18730  .011628
        1 18731  .007663
        1 18732  .018061
        1 18735 -.021475
        1 18736  .004771
        1 18737  .023742
        1 18738  .038033
        1 18739        0
        1 18742 -.012511
        1 18743   .01991
        1 18744  .006211
        1 18745  .021164
        1 18746 -.002591
        1 18749 -.005195
        1 18750 -.020888
        1 18751 -.007111
        1 18752 -.008953
        1 18753  .025294
        1 18756  .029075
        1 18757  .015411
        1 18758 -.044688
        1 18759  .022065
        1 18760 -.004318
        1 18763 -.034692
        1 18764  -.02336
        1 18765  .014719
        1 18766   .06981
        1 18767 -.007627
        1 18770 -.040991
        1 18771 -.004452
        1 18772  .084973
        1 18773  .017312
        1 18774  .002431
        1 18777        0
        1 18778   .02021
        1 18779 -.053883
        1 18780  .008375
        1 18781  .047342
        1 18784 -.047581
        1 18785 -.010824
        1 18786 -.044613
        1 18787  .018502
        1 18788  .008651
        1 18791  .020583
        1 18792  .005882
        1 18793 -.044277
        1 18794 -.030594
        1 18795        0
        1 18798 -.018034
        1 18799  .057851
        1 18800 -.011285
        1 18801  .018437
        1 18802 -.005172
        1 18805 -.004333
        1 18806  .024369
        1 18807  .005947
        1 18808  .029561
        1 18809 -.003281
        1 18812        0
        1 18813  .004115
        1 18814 -.006557
        1 18815  .026403
        1 18816 -.030547
        1 18819 -.015755
        1 18820  -.00674
        1 18821  .016964
        1 18822 -.035863
        1 18823  -.00173
        1 18826 -.012132
        end
        format %tdMon_dd,_CCYY date
        .
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input str7 firmid int date byte marketid
        "tesla"   22081 1
        "nissan"  22081 2
        "gm"      22081 1
        "bmw"     22081 2
        "hyundai" 22081 2
        "renault" 22081 2
        "vw"      22081 2
        "byd"     22081 2
        "mits"    22081 2
        "toyota"  22081 2
        "tesla"   21759 1
        "nissan"  21759 2
        "gm"      21759 1
        "bmw"     21759 2
        "hyundai" 21759 2
        "renault" 21759 2
        "vw"      21759 2
        "byd"     21759 2
        "mits"    21759 2
        "toyota"  21759 2
        "tesla"   21662 1
        "nissan"  21662 2
        "gm"      21662 1
        "bmw"     21662 2
        "hyundai" 21662 2
        "renault" 21662 2
        "vw"      21662 2
        "byd"     21662 2
        "mits"    21662 2
        "toyota"  21662 2
        "tesla"   21614 1
        "nissan"  21614 2
        "gm"      21614 1
        "bmw"     21614 2
        "hyundai" 21614 2
        "renault" 21614 2
        "vw"      21614 2
        "byd"     21614 2
        "mits"    21614 2
        "toyota"  21614 2
        end
        format %tdMon_dd,_CCYY date
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input byte marketid int date double(marketreturn factor1 factor2)
        1 18687   -.00043  -.01574  .002081
        1 18688  -.006875  .001615 -.004932
        1 18689   .004025  .017219 -.002478
        1 18690   .001452 -.007378 -.001046
        1 18693  -.005107 -.008341  .001309
        1 18694  -.004844  .008923  .003922
        1 18695 8.700e-06 -.001362 -.001042
        1 18696  -.019489 -.018871  .007299
        1 18697  -.005121   .00708  -.00647
        1 18700  -.016551 -.006049   -.0056
        1 18701    -.0368   -.0112 -.000262
        1 18702   .002261 -.019495  .004585
        1 18703   .017579  .013398 -.008346
        1 18704   .007423  .004302 -.004208
        1 18707   .015756  .014994 -.004226
        1 18708   .010206 -.003551  .000133
        1 18709  -.002114  .002914  .005039
        1 18710   .010262  .009341 -.001715
        1 18711  -.000384  .003161  .007402
        1 18714  -.002981 -.002748 -.001181
        1 18715  -.004311   .00706  .001576
        1 18716   .010758  .006685 -.001705
        1 18717  -.000067 -.001829 -.003416
        1 18718   .003837  .004963 -.000395
        1 18721   .006103  .000345  .001055
        1 18722   -.00388  -.00018 -.000395
        1 18723   .006198  .002184 -.004876
        1 18724  -.003322  -.00152  .001059
        1 18725   .013404 -.004004 -.006879
        1 18728   .000136 -.002793 -.000133
        1 18729  -.012744 -.007777 -.002798
        1 18730   .007032   .00019  .001737
        1 18731  -.003513  .000084 -.003868
        1 18732  -.001859  .003925  .001874
        1 18735  -.020828 -.011018  .008954
        1 18736   .004326  .005731 -.006225
        1 18737     .0263  .013515 -.008796
        1 18738   .010745  .005277 -.004975
        1 18739    .00012        0        0
        1 18742  -.002812 -.001593 -.000135
        1 18743    .00474   .00898 -.002027
        1 18744   .001624   .00625 -.004334
        1 18745   .017094  .003555 -.005441
        1 18746   .002634  .002301 -.002598
        1 18749   .006724 -.001753  .000274
        1 18750  -.007204 -.003379  .002605
        1 18751  -.009604 -.006855 -.001504
        1 18752  -.013355  -.00907  .015884
        1 18753    .00017   .00382  .008761
        1 18756  -.014009  .004544 -.001336
        1 18757   .011237  .008074 -.001739
        1 18758  -.001081 -.011111   .00965
        1 18759  -.013559  .004895 -.001195
        1 18760  -.004077 -.008067  .006911
        1 18763  -.003602 -.006204 -.003828
        1 18764  -.011572 -.000369 -.000928
        1 18765   .009424  .008804  .001061
        1 18766   .003357  .002178 -.004769
        1 18767  -.006488 -.007688   .00426
        1 18770  -.024202 -.011926  .008749
        1 18771   .004912 -.000827 -.002891
        1 18772   .002183  .003183  .000659
        1 18773   .006937  .003953 -.005005
        1 18774   .014042  .004081 -.007942
        1 18777  -.000542        0  .000133
        1 18778     .0148  .010593 -.004269
        1 18779  -.003265 -.022785  .000536
        1 18780  -.014868 -.001225 -.004687
        1 18781   .001888 -.009734 -.007399
        1 18784  -.003507  -.01076  .002304
        1 18785   .003999 -.000956 -.005815
        1 18786  -.010918 -.004187  .005577
        1 18787   .001532  .007378  .003517
        1 18788  -.015738  -.01398  .008222
        1 18791   .000809  .000669 -.003877
        1 18792   .013411  .012612 -.002416
        1 18793   -.01646 -.017432  .017086
        1 18794  -.016412  .001754  .001984
        1 18795   .009279  .003045 -.010033
        1 18798   -.00472  .005395  .000533
        1 18799   .016931  .013423 -.006531
        1 18800   .003095 -.006468   .00322
        1 18801  -.026216 -.002828   .00896
        1 18802   .003432 -.011726  .002916
        1 18805   .000683  .009184   -.0037
        1 18806    .00935  .012944 -.004377
        1 18807   .018571  .008283 -.004929
        1 18808   .016316  .010119 -.005222
        1 18809   .004913   .01441  .000673
        1 18812   .006381        0 -.000941
        1 18813  -.002768 -.001336   .00552
        1 18814  -.006855  .001002  .005757
        1 18815   .004635  .010454  -.00213
        1 18816  -.006642 -.006961  .002935
        1 18819  -.024389  -.01809  .010774
        1 18820  -.008209 -.004434 -.002369
        1 18821   .016742  .003106 -.007915
        1 18822  -.007637 -.006716  .000532
        1 18823  -.003439  .005554 -.001595
        1 18826   -.01684  -.00813  .004659
        end
        format %tdMon_dd,_CCYY date
        Thank you

        Comment


        • #5
          Okay thanks so much for a better example. The error Stata is spitting at you is because in your using data, your panel variable and your date variable do not uniquely ID each other. Suppose we have 2 observations and one unit whose ID=1 and we have 1970 in both observations for time. Well, unit 1 is now no longer a unique ID, since 1970 appears twice. My advice to you is to go to your using dataset and do
          Code:
          isid unit_var time_var
          and it SHOULD say that they do not uniquely ID each other. There are a few potential solutions for this, but use this one-liner in your using file and let's see what Stata says.

          Comment


          • #6
            Dear Jared,
            Thank you so much for the explanation, and yes, it says that "variables do not uniquely identify the observation".

            Comment

            Working...
            X