Announcement

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

  • Theoretical question about -predict- command

    Dear all,

    I am currently using -predict- to do the out-of-sample predictions. However, there is a theoretical uncertainty raised during my work. Could you possibly take a look and give me some ideas?

    That is, it doesn't matter whether the time series operators are used or not in -regress-, -predict- only generates the prediction in time t, is that correct? If so, continue to use F1.operator in a realized prediction of the dependent variable in -regress- after using -predict-, can it possibly generate a predicted alpha in time t+1?


    Many thanks for your help in advance!

  • #2
    You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    Predict normally predicts the dv or some other statistic. It can do in and out of sample predictions assuming all the iv's are available. But, if you regress y(t) on x(t) or x(t-1), then the model should predict y(t) (or related statistics in t). You seem to want it to predict y(t+1) but it has not estimated the parameters to make that prediction. You can estimate a model like y(t+1) on x(t) and x(t-1) if you want to predict y(t+1).

    Comment


    • #3
      @ Phil Bromile Hi Phil, thank you for your reply!

      Here is my data:
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float exret_m double mktrf float(P1 P2 ym)
      -.0010275785  -.050399999999999806 1 1 252
       -.037058156   .005600000000000034 1 1 253
         .05429238    .03560000000000003 1 1 254
         .00736598  -.020999999999999925 1 1 255
        .019176433  .0010999999999999938 1 1 256
        -.04318568  -.023600000000000055 1 1 257
        -.03732651  -.015399999999999959 1 1 258
        -.11005977   -.07029999999999965 1 1 259
        -.14016296    -.0716999999999999 1 1 260
          .0392986   .049200000000000306 1 1 261
       -.032197274    .03359999999999989 1 1 262
        -.04497838  -.036500000000000164 1 1 263
        -.02502831  -.032400000000000234 1 1 264
        -.07564716  -.058599999999999826 1 1 265
       -.029289363  -.018699999999999953 1 1 266
         .03762526    .03270000000000013 1 1 267
        -.03818964   -.03989999999999978 1 1 268
        -.05297857  -.030900000000000177 1 1 269
        -.05291183  -.031900000000000144 1 1 270
         .03681149    .11140000000000044 1 1 271
         .00208415   .012900000000000059 1 1 272
         .11712262    .11299999999999968 1 1 273
         .04921977    .04669999999999991 1 1 274
      -.0002171315   .005500000000000017 1 1 275
          .1605438    .03599999999999973 1 1 276
       .0039334097    .02590000000000003 1 1 277
         .04842993                 .0282 1 1 278
         .08474688    .06670000000000058 1 1 279
         .15045163   .005200000000000037 1 1 280
         .06409056   .030699999999999988 1 1 281
       -.029305244   -.04069999999999972 1 1 282
        -.06758389 -.0049999999999999515 1 1 283
         -.0493464    .00919999999999997 1 1 284
         -.0903986   -.03439999999999986 1 1 285
      -.0016575655   .021600000000000067 1 1 286
        -.04192865  -.017800000000000066 1 1 287
        .010908174   -.01919999999999988 1 1 288
        -.07043324   -.04819999999999998 1 1 289
       -.008817618   .006299999999999976 1 1 290
        -.05694075 -.0052000000000000275 1 1 291
        -.05357403   -.05969999999999965 1 1 292
        -.01940334   .018200000000000157 1 1 293
         -.0943615  -.027400000000000077 1 1 294
         .05498044    .10279999999999995 1 1 295
        -.01583879  -.008000000000000005 1 1 296
        -.05473363   -.00839999999999997 1 1 297
        -.07375218   -.01759999999999989 1 1 298
        -.04214488    .01839999999999993 1 1 299
         .13239744     .0798999999999994 1 1 300
           .074498    .01219999999999999 1 1 301
       -.017922886   -.00839999999999997 1 1 302
        -.02704268  -.009599999999999945 1 1 303
       -.009513986    .05089999999999999 1 1 304
       -.027150584   .012700000000000003 1 1 305
       -.012957978  -.007400000000000042 1 1 306
       -.003898965  -.010200000000000094 1 1 307
       -.067859694  -.045400000000000384 1 1 308
       -.018804455   .040200000000000125 1 1 309
        .008969169    .06480000000000065 1 1 310
        -.01991087    .03880000000000014 1 1 311
          .0415929   .006499999999999962 1 1 312
        .032496493    .07130000000000054 1 1 313
         .05544817    .04879999999999996 1 1 314
        .012421038  -.013100000000000002 1 1 315
        .024127023    .04620000000000015 1 1 316
        .005498156   .010299999999999978 1 1 317
         -.0774667   -.06449999999999977 1 1 318
       -.002492504    .06070000000000039 1 1 319
        -.05506967   -.08599999999999933 1 1 320
        .005575916   .046600000000000044 1 1 321
       -.008731282   .011699999999999969 1 1 322
         -.0642863   -.03270000000000014 1 1 323
           .122155    .12469999999999933 1 1 324
          .0762641    .04390000000000033 1 1 325
         .04607746   .016399999999999974 1 1 326
         -.0145491  -.021099999999999914 1 1 327
        .016849674   .001099999999999993 1 1 328
        .011400106    .03940000000000021 1 1 329
        .032950174   .038500000000000395 1 1 330
       -.034531295    .03519999999999977 1 1 331
        -.02737532   -.02590000000000003 1 1 332
        -.29257116    -.2323999999999987 1 1 333
        -.05447609   -.07770000000000009 1 1 334
        -.05596156     .0681000000000004 1 1 335
         .08671752    .04209999999999985 1 1 336
        .036950354   .047499999999999716 1 1 337
         .05397591   -.02270000000000021 1 1 338
        .008877028   .005599999999999993 1 1 339
        -.03252491  -.002899999999999986 1 1 340
        .011637847   .047899999999999755 1 1 341
       -.008469204  -.012500000000000103 1 1 342
        -.05081187   -.03309999999999969 1 1 343
       -.016527556    .03299999999999984 1 1 344
       -.036147784   .011499999999999913 1 1 345
        -.06153427   -.02289999999999993 1 1 346
        -.02523398   .014899999999999929 1 1 347
          .0910867    .06099999999999995 1 1 348
       -.004402882   -.02250000000000011 1 1 349
        .009269149   .015699999999999888 1 1 350
        .010437378   .043299999999999984 1 1 351
      end
      format %tm ym
      Here is my code:

      Code:
      egen group = group(P1 P2)  // P1 and P2 are portfolios 1, 2, 3 and 4
      gen p = .
      levelsof ym, local(ym)
      foreach i in ym {
      xtset group ym
         reg F1.exret_m mktrf if inrange(`i', 252, 467)
         predict predicted_return if inrange(`i', 468, 671)
         replace p =  predicted_return if inrange(`i', 468, 671)
        }
      
      gen alpha = .
      levelsof group, local(group)
      foreach i in group {
      reg predicted_return mktrf if group == `i'
       replace alpha = _b[_cons] if group == `i'
      }
      If I want the prediction to be at y(t+1), you mean I would need to regress F.exret_m on mktrf and L.mktrf:

      reg F.exret_m mktrf L.mktrf if inrange(`i', 252, 467)
      Is that correctly? If so, would you please explain the rationale behind it? Many thanks!
      Last edited by Jae Li; 30 Jun 2018, 06:49.

      Comment

      Working...
      X