Announcement

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

  • date is not regularly spaced r(198); With data example

    Dear Stata community,

    Consider the following data example;

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float date double decile float excess_return double twelvemonth_excessmarket float gap
    491  1  .063026816    -.12125222816835543 .
    491  2    .3472045    -.13262046376720865 .
    491  3     .164835    -.13423541289209015 .
    491  4   .10501367    -.13608913451708093 .
    491  5   .25025338    -.13989141276340664 .
    491  6    .4833296    -.12101875306672277 .
    491  7  .034963112    -.13071168498112226 .
    491  8 -.068205506    -.11218231642787713 .
    491  9    .3745836       -.10459308446125 .
    491 10    .3608507     -.0999869672928918 .
    492  1    .3959069    -.12561071944962682 .
    492  2    .4369581    -.11788863066935919 .
    492  3    .2021112    -.13156970714878766 .
    492  4   .25052503    -.13126882132799486 .
    492  5    .3166758    -.12621354034340426 .
    492  6    .6718242    -.12361882920344756 .
    492  7   .20170496     -.1305232844960416 .
    492  8     .381151    -.11331580789034923 .
    492  9   .22656704    -.09753528664280524 .
    492 10    .5776748    -.10200830339889326 .
    493  1    .2464361    -.17913782809583884 .
    493  2    .2928051    -.16653858790430964 .
    493  3   .11025526     -.1767609176094556 .
    493  4   .21125513    -.17966905020684804 .
    493  5   .17320582    -.17258808091935074 .
    493  6   .24593826    -.16698299465679137 .
    493  7    .1621037    -.17482212998037322 .
    493  8    .1701565     -.1791465483943688 .
    493  9   .11074493    -.15910045928733563 .
    493 10    .3263901    -.15210531562806845 .
    494  1    .3140025     -.1015801023992762 .
    494  2     .147183    -.08292336492744985 .
    494  3   .22907856    -.10084289523111016 .
    494  4   .30621445     -.0966479677295549 .
    494  5    .2203166    -.10339275904422852 .
    494  6   .28207207    -.10339858800711971 .
    494  7    .1521585    -.09947695372846238 .
    494  8   .08194132    -.09458978851981766 .
    494  9   .14560072    -.08463484464652757 .
    494 10   .26948842    -.07679740917040855 .
    495  1    .6551385    .007980907364075777 .
    495  2     .353177    .006763600784813619 .
    495  3    .3957881  -.0021291154506072854 .
    495  4    .6129454    .003490245485469295 .
    495  5    .4105932   .0008881489934099505 .
    495  6   .29242247 -.00015210372675395552 .
    495  7   .25555873    .006402111074997372 .
    495  8   .58451873    .009476617950391435 .
    495  9   .27677798    .014235802246559872 .
    495 10    .5220298    .017542048237789192 .
    496  1   .18721493    -.10376831537200717 .
    496  2   .23251167    -.09888738516776385 .
    496  3    .5786744    -.11779272848636188 .
    496  4    .3152326    -.11958727321909955 .
    496  5    .3733563    -.10440249931849138 .
    496  6   .28131652    -.11479569555862595 .
    496  7    .2809173    -.10511100503378838 .
    496  8    .7556632    -.08902262493774739 .
    496  9    .5113395     -.0969044559650601 .
    496 10    .4913411    -.11590786297024484 .
    498  1  -.10185333    -.16301141646455292 1
    498  2    .1364627    -.15726786272020044 1
    498  3   .22664863    -.16103306078894478 1
    498  4   .24587746     -.1591803721383517 1
    498  5    .5730114    -.16421729542886535 1
    498  6    .2377301     -.1460255944099909 1
    498  7    .2146625    -.16472689560113965 1
    498  8    .4586159    -.14707639703071354 1
    498  9    .2020423    -.15337363129324103 1
    498 10     .405316     -.1429057527977514 1
    499  1  -.31411844    -.20530763198951366 .
    499  2   -.1778079     -.1951994918951318 .
    499  3   .05007065     -.1842508025045699 .
    499  4 -.002626595    -.19746926327879322 .
    499  5    .3942898    -.19386422868320485 .
    499  6   .09807744    -.17668552653362252 .
    499  7   .20794877     -.1919781397450857 .
    499  8   .09493694    -.19820327069825502 .
    499  9   .07073201    -.21084521936152792 .
    499 10   .15410985     -.1786834267479006 .
    500  1  -.26448777     -.1374838717757109 .
    500  2  -.17195845    -.13530279185076602 .
    500  3  .067911625    -.14593798427081076 .
    500  4   .03195808    -.14602658449724026 .
    500  5    .6965067    -.14065331718226662 .
    500  6  -.05837285    -.13448764911624028 .
    500  7    .1954586     -.1378673806108558 .
    500  8   .05223574    -.13732616755008148 .
    500  9    .2764815     -.1474571475704539 .
    500 10   .22997856     -.1378606723097311 .
    501  1   -.2571248    -.10524676551040461 .
    501  2   -.1268876    -.10586595182851201 .
    501  3   .09914548     -.1347283880723883 .
    501  4    .2246819     -.0903700699311062 .
    501  5    .3568679    -.10868100807192685 .
    501  6  .002753427    -.10924279354227937 .
    501  7   .29398292     -.1002972075366649 .
    501  8   .25337133    -.11611616370046547 .
    501  9    .4067111    -.11522783868150095 .
    501 10    .1610342    -.10455593707587973 .
    end
    When I run;
    Code:
    xtset decile date
    I get;

    Panel variable: decile (strongly balanced)
    Time variable: date, 491 to 501, but with gaps
    Delta: 1 unit

    If I then try to run;

    Code:
    by decile: newey excess_return twelvemonth_excessmarket, lag(17)
    I get;

    date is not regularly spaced
    r(198);


    What suggestions do you have?

    Kind regards, Julien Maas
    Last edited by Julien Maas; 10 Dec 2023, 17:36.

  • #2
    See this thread: https://www.statalist.org/forums/for...gularly-spaced

    Comment


    • #3
      Originally posted by Julien Maas View Post

      Panel variable: decile (strongly balanced)
      Time variable: date, 491 to 501, but with gaps
      Delta: 1 unit

      If I then try to run;

      Code:
      by decile: newey excess_return twelvemonth_excessmarket, lag(17)
      A lag of 17 does not make sense with only 10 available time points. The error should be as a result of missing values, so to override it, you need to make an assumption that the available observations are equally spaced. You may install newey2 from SSC and use the -force- option which does exactly this.

      Code:
      ssc describe newey2

      Comment


      • #4
        This may be obvious, but the gap is no data for 497. (June 2001?)

        Is this all the data, or just enough to show the problem?

        Comment


        • #5
          First of all thank you all for the swift responses!

          The dataset I am using is much larger, yet this is just an example. The gap in the example data is indeed for 497, yet likewise I have more gaps in the larger dataset I am using that I think stop the newey command from running when using a lag to correct for autocorrelation.

          Running newey without the lags still works, yet then I do not have the correction for autocorrelation. I am guessing I just have too many missing values, yet I am not entirely sure how to deal with them.

          Yet even if I use a lag of 2 instead of 17 in the exampe above, I still get an error message.


          EDIT (ISSUE SOLVED):

          I just ran newey2,force on the example dataset posted above without running it by decile, and that works, even with 17 lags.

          I checked again to see if I can apply newey2 on the larger dataset, and it works if I collapse the data first by decile and date.

          This is the code;

          Code:
          collapse excess_return twelvemonth_excessmarket if !missing(decile), by(decile date)
          
          xtset decile date
          
          newey2 excess_return twelvemonth_excessmarket, lag(17) force
          
          forvalues i = 1/10 {
          newey2 excess_return twelvemonth_excessmarket if decile == `i' , lag(17) force
          disp `i'
          }
          Last edited by Julien Maas; 11 Dec 2023, 13:21.

          Comment

          Working...
          X