Announcement

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

  • Business Calendar

    For my project, I have financial data, which is missing on weekends.

    A regression I am using for example is:
    Code:
    reg F2.FTSE100 UKIS EPU rmrf L1.rmrf L2.rmrf L3.rmrf L4.rmrf l5.rmrf
    no observations
    r(2000);
    Which is the return on (t+2) for FTSE data on my x variable UKIS (which is a search index), EPU (Economic Policy Uncertainty index) and 5 lags of rmrf (UK market excess returns). I am encountering a problem of no observations as there is missing values in the financial data.

    I am attempting to create a business calendar where I have formatted the data to
    Code:
    format %tbsimple:NN/DD/CCYY date
    on my master file, so the lags and forward operators do not take the missing values. However this does not seem to work.

    Data:
    Code:
    input int date double FTSE100 float UKIS double(EPU rmrf)
    16253 4424.72           .  75.14 -.00833516
    16254  4407.4   -.2180105  30.11 -.00400119
    16255       .    .3280379  46.34          .
    16256       .   -.1164731  41.63          .
    16257 4403.28   -.5526805 276.08 -.00167145
    16258 4370.74   .25532183 167.46 -.00767937
    16259 4358.37     .381967 257.54 -.00251354
    16260 4381.11   -.3521871  27.22  .00334938
    16261 4393.18    .1600098      0  .00217685
    16262       .  .016313126 103.71          .
    16263       .  -.11036982 250.09          .
    16264 4359.97 -.024156913 204.16 -.00654372
    16265 4357.74    .1126608 296.38  -.0001302
    16266 4372.55   -.1054983 113.19  .00177553
    16267 4340.71   .16306344  54.77 -.00682801
    16268 4339.23  .067925915  60.37  .00029166
    16269       .   .06046037  81.68          .
    16270       .  -.19248436 118.62          .
    16271  4321.1   .08850786  40.17 -.00396609
    16272 4339.37  .014100888 113.13  .00276665
    16273  4377.3    .2632147 324.83  .00808184
    16274 4306.25    -.344536  187.1 -.01562203
    16275 4326.34    .2210378      0  .00353599
    16276       .   .05127193 221.74          .
    16277       .  -.26678687 120.89          .
    16278 4287.04    .2210185 109.95 -.00932341
    16279 4324.86   -.0252831   91.8  .00760169
    16280 4356.25  -.17771873  70.81  .00628228
    16281  4418.7   .05900541   90.4  .01296797
    16282 4413.08   .05729766 187.06 -.00102673
    16283       . -.022344263 192.76          .
    16284       .  -.02866241   76.2          .
    16285 4415.73   .17142993 221.81  .00017013
    16286 4429.68  -.14051646 101.81  .00264746
    16287 4408.07  -.25682688 296.88  -.0049213
    16288 4413.37    .1975079  211.1  .00093802
    16289 4337.88   -.0490886  174.4 -.01626284
    16290       .    .1140014 105.11          .
    16291       .   .05550234 100.87          .
    16292  4314.4   -.1717474  106.9 -.00601042
    16293 4350.88    .2153931 128.45  .00781587
    16294 4312.16  -.19072935  46.66 -.00483969
    16295 4328.11   .27155307 223.24  .00312112
    16296 4301.53 -.034338232  81.92 -.00561349
    16297       .  -.25229073 126.45          .
    16298       .   .03926425 214.99          .
    16299 4350.17  .001884974  51.98  .00977664
    16300 4358.68   -.0753112 100.24  .00211764

  • #2
    You don't show the bcal creation steps, and without an MWE it's hard to know what is going wrong.

    I suspect you need something like this:

    Code:
    clear
    input int date double FTSE100 float UKIS double(EPU rmrf)
    16253 4424.72           .  75.14 -.00833516
    16254  4407.4   -.2180105  30.11 -.00400119
    16255       .    .3280379  46.34          .
    16256       .   -.1164731  41.63          .
    16257 4403.28   -.5526805 276.08 -.00167145
    16258 4370.74   .25532183 167.46 -.00767937
    16259 4358.37     .381967 257.54 -.00251354
    16260 4381.11   -.3521871  27.22  .00334938
    16261 4393.18    .1600098      0  .00217685
    16262       .  .016313126 103.71          .
    16263       .  -.11036982 250.09          .
    16264 4359.97 -.024156913 204.16 -.00654372
    16265 4357.74    .1126608 296.38  -.0001302
    16266 4372.55   -.1054983 113.19  .00177553
    16267 4340.71   .16306344  54.77 -.00682801
    16268 4339.23  .067925915  60.37  .00029166
    16269       .   .06046037  81.68          .
    16270       .  -.19248436 118.62          .
    16271  4321.1   .08850786  40.17 -.00396609
    16272 4339.37  .014100888 113.13  .00276665
    16273  4377.3    .2632147 324.83  .00808184
    16274 4306.25    -.344536  187.1 -.01562203
    16275 4326.34    .2210378      0  .00353599
    16276       .   .05127193 221.74          .
    16277       .  -.26678687 120.89          .
    16278 4287.04    .2210185 109.95 -.00932341
    16279 4324.86   -.0252831   91.8  .00760169
    16280 4356.25  -.17771873  70.81  .00628228
    16281  4418.7   .05900541   90.4  .01296797
    16282 4413.08   .05729766 187.06 -.00102673
    16283       . -.022344263 192.76          .
    16284       .  -.02866241   76.2          .
    16285 4415.73   .17142993 221.81  .00017013
    16286 4429.68  -.14051646 101.81  .00264746
    16287 4408.07  -.25682688 296.88  -.0049213
    16288 4413.37    .1975079  211.1  .00093802
    16289 4337.88   -.0490886  174.4 -.01626284
    16290       .    .1140014 105.11          .
    16291       .   .05550234 100.87          .
    16292  4314.4   -.1717474  106.9 -.00601042
    16293 4350.88    .2153931 128.45  .00781587
    16294 4312.16  -.19072935  46.66 -.00483969
    16295 4328.11   .27155307 223.24  .00312112
    16296 4301.53 -.034338232  81.92 -.00561349
    16297       .  -.25229073 126.45          .
    16298       .   .03926425 214.99          .
    16299 4350.17  .001884974  51.98  .00977664
    16300 4358.68   -.0753112 100.24  .00211764
    end
    
    format %tdNN/DD/CCYY date
    bcal create my_cal, from(date) replace excludemissing(FTSE100) gen(my_date)
    tsset my_date, format(%tdNN/DD/CCYY)
    
    reg F2.FTSE100 UKIS EPU L(0(1)5)rmrf

    Comment


    • #3
      Thank you Dimitriy. Unfortunately I am getting this error with the code:

      Code:
       bcal create my_cal, from(date) replace excludemissing(FTSE100) gen(my_date)
      Stata date cannot be after Dec 31, 9999
      r(198);

      Comment


      • #4
        ^I have sorted this issue

        I can see that the dates are in order without weekend dates now. Would the above code line up the right figures for the rest of the variables in my dataset, not just the FTSE100 variables? For example are the UKIS and EPU variables still lined up to their respective correct dates?

        Comment


        • #5
          It should be if they are all missing on the same days (weekends).

          Comment

          Working...
          X