Announcement

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

  • "no result for all obs: reg exret_m mktrf smb hml" by -rangestat-

    Dear Statalists,

    I am having a trouble with running rolling regressions by -rangestat-. After running the code:
    Code:
    rangestat (reg) exret_m mktrf smb hml, interval(quarter -2 0) by(permno P1 double_P2)
    The command window shows an error
    no result for all obs: reg exret_m mktrf smb hml
    Can I ask, there is any professional who knows where is wrong? Many thanks in advance!!

    This is my partial dataset: (P1 is the first-sorted quartile portfolio with 1-4 and double_P2 is the second-sorted quartile portfolio with 1-4)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double permno float(ym quarter exret_m) double(mktrf smb hml) float(P1 double_P2)
    10001 623 207     .05183491                 .0074 -.0070999999999999995                 .0174 1 2
    10001 626 208     .04875993                 .0311 -.0060999999999999995                 .0087 1 2
    10001 629 209   -.027325016   .038900000000000004                 .0077                 .0044 1 2
    10001 632 210    .000401006                 .0273                  .005                 .0152 1 2
    10001 635 211   -.015331147                 .0118                 .0147                 .0355 1 2
    10001 638 212     .03068413                 .0403                 .0079                -.0026 1 2
    10001 641 213    .006323002                 -.012   .012199999999999999                -.0019 1 2
    10001 644 214    .004411765                 .0377                 .0294                -.0118 1 2
    10001 650 216      .0795941                 .0043                -.0189                 .0509 1 2
    10001 653 217    .009056263   .026099999999999998   .030600000000000002                -.0074 1 2
    10001 656 218     .05097524                -.0197                -.0382  -.012199999999999999 1 2
    10001 659 219    -.03782605                -.0006                 .0254                 .0207 1 2
    10001 662 220 -.00049508293  -.011200000000000002                 .0305 -.0045000000000000005 1 2
    10001 665 221     .03000002  -.015300000000000001                 .0281  -.008100000000000001 1 2
    10001 668 222   .0033669735                -.0308                -.0264                 .0053 1 2
    10001 671 223    -.13225102                -.0217                -.0281  -.025699999999999997 1 2
    10001 611 203     .05219088                 .0682   .006999999999999999                 .0381 1 3
    10001 614 204    .072304375  .0045000000000000005   .026000000000000002                -.0155 1 3
    10001 617 205    .008260886                -.0175                -.0018                -.0031 1 3
    10001 620 206    .005009129                -.0759                -.0348                -.0146 1 3
    10001 647 215    -.05885783                 .0281                 -.005                 -.003 1 4
    10001 608 202      .0764596    .09539999999999999                 .0392  -.031200000000000002 . .
    10002 512 170    -.04059999                -.1035   .025699999999999997                 .0131 1 3
    10002 515 171     .05739056                -.0576                     0                 .0225 1 3
    10002 518 172     .09560374                 .0109                 .0089                -.0209 1 3
    10002 521 173     .04015751   .014199999999999999                 .0167                 .0066 1 3
    10002 524 174    -.05424933                -.0124                 .0079                 .0002 1 3
    10002 527 175     .02264745                 .0429                -.0301                 .0242 1 3
    10002 530 176   -.024722686                -.0132                 .0175                 .0021 1 3
    10002 554 184    .006272808                 .0146                 .0355  .0060999999999999995 1 3
    10002 572 190   -.013052215                 .0322                -.0229  -.018600000000000002 1 4
    10002 533 177     .03015792   .018600000000000002                 .0226                 .0138 2 1
    10002 536 178     .05173647                  .016                 .0304                -.0025 2 1
    10002 539 179     .15990242   .034300000000000004                 .0012                -.0006 2 1
    10002 542 180   -.015181378                -.0197  -.013999999999999999   .015600000000000001 2 1
    10002 545 181   -.007863974   .005699999999999999                 .0262                 .0262 2 1
    10002 548 182    -.11130605                 .0049                -.0058                 .0077 2 1
    10002 551 183  -.0007222957                -.0025                -.0046                 .0044 2 1
    10002 557 185     .08456084 -.0034999999999999996 -.0034999999999999996                 .0087 2 1
    10002 560 186     .05126724                 .0184                -.0137                 .0005 2 1
    10002 563 187     .05547961                 .0087  -.011000000000000001                 .0316 2 1
    10002 566 188    -.04485884  .0068000000000000005                -.0006                -.0022 2 1
    10002 569 189     .05039117                -.0196                 .0077                -.0113 2 1
    10002 587 195     .19310904                 .0174                 .0359                -.0024 2 1
    10002 590 196     .04160328                 .0895                -.0009                 .0352 2 1
    10002 593 197     -.2830736                 .0043   .026099999999999998                -.0271 2 1
    10002 596 198    -.04042261                 .0408                 .0245                 .0092 2 1
    10002 599 199     .03600105                 .0275                 .0611                 .0001 2 1
    10002 602 200     .07054011    .06309999999999999   .014199999999999999                  .021 2 1
    10002 605 201     -.1648855                -.0556                -.0197                 -.045 2 1
    10002 608 202   -.016229017    .09539999999999999                 .0392  -.031200000000000002 2 1
    10002 611 203     .06364505                 .0682   .006999999999999999                 .0381 2 1
    10002 614 204   -.068281844  .0045000000000000005   .026000000000000002                -.0155 2 1
    10002 617 205     .05327864                -.0175                -.0018                -.0031 2 1
    10002 620 206             0                -.0759                -.0348                -.0146 2 1
    10002 623 207      -.283237                 .0074 -.0070999999999999995                 .0174 2 1
    10002 626 208      .1153847                 .0311 -.0060999999999999995                 .0087 2 1
    10002 629 209    .017006787   .038900000000000004                 .0077                 .0044 2 1
    10002 632 210     .02748618                 .0273                  .005                 .0152 2 1
    10002 635 211    .010845805                 .0118                 .0147                 .0355 2 1
    10002 578 192    -.01170908  -.009300000000000001   .009399999999999999                -.0015 2 2
    10002 581 193      -.333708   -.08439999999999999                 .0127  -.024300000000000002 2 2
    10002 584 194      .5684053                -.0924                -.0113                 .0633 2 2
    10002 575 191   -.020370636                -.0087                  .002                -.0052 2 3
    10002 509 169    .008576544                -.0721                 .0426                 .0013 . .
    10003 380 126    -.04807826                -.0159                 .0163                  -.01 1 2
    10003 383 127     -.2730308                 .1084                -.0223                -.0404 1 2
    10003 386 128     .13296364  -.026600000000000002                -.0104                 .0365 1 2
    10003 389 129     -.1762769  -.023399999999999997  -.030899999999999997                 .0341 1 2
    10003 395 131      .4062909   .015300000000000001   .016399999999999998                 .0252 1 2
    10003 398 132    -.03107143                  .023                 .0023   .012199999999999999 1 2
    10003 401 133    -.02173077                 .0031                 -.003   .026099999999999998 1 2
    10003 404 134    .033114288                -.0012                 .0311 -.0045000000000000005 1 2
    10003 407 135    -.07048182                 .0165   .012199999999999999   .005699999999999999 1 2
    10003 410 136         .0473                -.0478                -.0098                 .0131 1 2
    10003 413 137        -.1031  -.030299999999999997  -.004699999999999999                 .0168 1 2
    10003 422 140     -.0903143                 .0219  -.006999999999999999  -.010700000000000001 1 2
    10003 428 142    .070700005                 .0335  -.021099999999999997                -.0077 1 2
    10003 392 130     .29151765   .011899999999999999   .005600000000000001                -.0021 1 3
    10003 416 138     -.0989381                -.0231                 .0282                -.0191 1 3
    10003 419 139        -.1044                 .0086                 .0003                 .0053 1 3
    10003 425 141     .51910955   .027200000000000002   .029300000000000003                -.0227 1 3
    10003 377 125     -.3145448  -.049400000000000006                 .0006   .012199999999999999 1 4
    10003 317 105     .05577561                 .0103                -.0091   .013999999999999999 2 4
    10003 320 106    -.06219231                 -.086   .022799999999999997                 .0318 2 4
    10003 323 107    -.05428272                -.0327  .0007000000000000001                 .0033 2 4
    10003 326 108        -.0047   .016399999999999998                 .0037   .016399999999999998 2 4
    10003 335 111    -.03838276                 .0681                 .0013                -.0446 2 4
    10003 338 112     .02191579                -.0227   .061500000000000006                 .0075 2 4
    10003 341 113     .12261678                 .0479                 .0212  -.011000000000000001 2 4
    10003 344 114    -.11463374                  .033                -.0125 -.0068000000000000005 2 4
    10003 347 115    .007033334                 .0149                 .0195  -.015600000000000001 2 4
    10003 350 116     .06682941   .015700000000000002                 .0073   .004699999999999999 2 4
    10003 353 117     -.1966425  -.013500000000000002                -.0102                 .0219 2 4
    10003 356 118    -.07692254                -.0076  .0028000000000000004                -.0134 2 4
    10003 359 119    -.26696956                 .0116                -.0241  .0028000000000000004 2 4
    10003 362 120     -.1858872                 .0183                 .0152  -.028999999999999998 2 4
    10003 365 121    -.18487144                -.0109                 .0143                -.0194 2 4
    10003 368 122    -.37334695  -.061200000000000004  -.036699999999999997                 .0073 2 4
    10003 371 123    -.23676923                 .0246   .008100000000000001  -.015600000000000001 2 4
    end
    format %tm ym
    format %tq quarter
    Last edited by Jae Li; 12 Dec 2017, 06:05.

  • #2
    Looking at permno 10001 in your sample data, you show only one observation per quarter. That means there will be at most 3 observations (from 3 quarters) in each regression. With three independent variables, those regressions will fail.

    It seems to me that your by option is too restrictive.

    Comment


    • #3
      @William Lisowski Thank you for your reply, William! Yes, the dataset is recorded as a quarterly-end basis, so one observation per quarter. Even though I only use one variable for the by option, it still didn't work. Do you possibly know how to adjust it?
      Last edited by Jae Li; 12 Dec 2017, 07:56.

      Comment


      • #4
        WIlliam is right. The only possible adjustments are to fit the same model to (much) more data or a simpler model. Personally I would need a really strong reason to fit even a one-predictor regression to 3 data points and one has yet to occur to me.

        Comment


        • #5
          @Nick Cox Thank you for your reply, Nick!

          I would like to run a rolling regression based on the doule-sorted quartile portfolios. That's why I fit a 3-predictor regression to 3 data points (i.e., company id, first sorts and second sorts). Also, when I ran it on the CAPM model, it works fine. However, I tried the same code on the Fama-French three-factor model, it shows the error. I tried a lot of methods but still didn't work out. If I just wanna run it, may I ask you that what can I do to fix it? Many thanks!
          Last edited by Jae Li; 12 Dec 2017, 08:11.

          Comment


          • #6
            I think your problem is conceptual, not a programming problem, and will require someone who understands the Fama-French model to address your needs. I am not a financial economist (nor is Nick) and I don't even begin to understand the technical description of your concerns in post #5.

            Comment


            • #7
              Sorry, but I really don't understand your answer in #5.

              Estimating four parameters from three data points is more than dubious; it's impossible. There is, on the face of it, nothing to fix here except not asking Stata to do the impossible.

              I don't know what you did with the CAPM model (I don't even know what that means, not being in your field, as William also points out) but if it worked you must have done something quite different.

              Perhaps there is a simple misunderstanding here in that the by() option insists on separate regressions for each group so specified.

              Comment


              • #8
                Perhaps a visual representation of a regression sample and the regression results will help. With the rolling regression code you showed in #1, you perform one regression per observation. For any given observation, you can manually view the sample and perform the regression that will produce results for that observation. In the example below, I choose observation 15. To simplify the code, I group permno P1 double_P2 together:

                Code:
                egen bygroup = group(permno P1 double_P2)
                gen target = bygroup == bygroup[15] & inrange(quarter, quarter[15]-2, quarter[15])
                list if target
                regress exret_m mktrf smb hml if target
                and the results:
                Code:
                . list if target
                
                     +-----------------------------------------------------------------------------------------------------+
                     | permno       ym   quarter     exret_m    mktrf      smb      hml   P1   double~2   bygroup   target |
                     |-----------------------------------------------------------------------------------------------------|
                 13. |  10001   2015m3    2015q1   -.0004951   -.0112    .0305   -.0045    1          2         1        1 |
                 14. |  10001   2015m6    2015q2         .03   -.0153    .0281   -.0081    1          2         1        1 |
                 15. |  10001   2015m9    2015q3     .003367   -.0308   -.0264    .0053    1          2         1        1 |
                     +-----------------------------------------------------------------------------------------------------+
                
                . regress exret_m mktrf smb hml if target
                note: mktrf omitted because of collinearity
                
                      Source |       SS           df       MS      Number of obs   =         3
                -------------+----------------------------------   F(2, 0)         =         .
                       Model |  .000551395         2  .000275698   Prob > F        =         .
                    Residual |           0         0           .   R-squared       =    1.0000
                -------------+----------------------------------   Adj R-squared   =         .
                       Total |  .000551395         2  .000275698   Root MSE        =         0
                
                ------------------------------------------------------------------------------
                     exret_m |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                       mktrf |          0  (omitted)
                         smb |  -1.369572          .        .       .            .           .
                         hml |  -7.557814          .        .       .            .           .
                       _cons |   .0072667          .        .       .            .           .
                ------------------------------------------------------------------------------
                
                .
                Even if you disregard P1 double_P2 and perform the rolling regressions on permno by-groups, you have the same problem because the data is a panel:
                Code:
                xtset permno quarter
                replace target = permno == permno[15] & inrange(quarter, quarter[15]-2, quarter[15])
                list if target
                regress exret_m mktrf smb hml if target
                and the results:
                Code:
                . list if target
                
                     +-----------------------------------------------------------------------------------------------------+
                     | permno        ym   quarter     exret_m   mktrf      smb      hml   P1   double~2   bygroup   target |
                     |-----------------------------------------------------------------------------------------------------|
                 13. |  10001    2013m9    2013q3    .0044118   .0377    .0294   -.0118    1          2         1        1 |
                 14. |  10001   2013m12    2013q4   -.0588578   .0281    -.005    -.003    1          4         3        1 |
                 15. |  10001    2014m3    2014q1    .0795941   .0043   -.0189    .0509    1          2         1        1 |
                     +-----------------------------------------------------------------------------------------------------+
                
                . regress exret_m mktrf smb hml if target
                note: mktrf omitted because of collinearity
                
                      Source |       SS           df       MS      Number of obs   =         3
                -------------+----------------------------------   F(2, 0)         =         .
                       Model |   .00960812         2   .00480406   Prob > F        =         .
                    Residual |           0         0           .   R-squared       =    1.0000
                -------------+----------------------------------   Adj R-squared   =         .
                       Total |   .00960812         2   .00480406   Root MSE        =         0
                
                ------------------------------------------------------------------------------
                     exret_m |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                       mktrf |          0  (omitted)
                         smb |   2.672653          .        .       .            .           .
                         hml |   3.257919          .        .       .            .           .
                       _cons |  -.0357208          .        .       .            .           .
                ------------------------------------------------------------------------------

                Comment


                • #9
                  @William Lisowski @Nick Cox @Robert Picard Hello William, Nick and Robert, thank you so much for giving me the comments and pointing out the issue with presenting examples. After a deep consideration, I realise that there is a fundamental mistake I've made during my programming so that's why I couldn't get proceed. Anyway, many thanks for your help and time indeed! A great lesson has been learnt today!

                  Comment

                  Working...
                  X