Announcement

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

  • constructing 2x3 portfolios through STATA

    Fama 5 factors model is r−Rf=α+β1(Rm−Rf)+β2⋅SMB+β3⋅HML+ β4 ⋅ RMW + β5 ⋅ CMA + e

    where Rf is risk free return, (Rm−Rf) is premium return and Rm is market return, SMB is the "Small Minus Big" market capitalization risk factor. HML is the "High Minus Low" value premium risk factor, RMW is the ''Robust minus Weak'' profitability risk factor. CMA is the ''Conservative minus Aggresively' investment risk factor.

    Please let mt detail my question. I have over over 1000 stocks and their yearly return ,yearly size, yearly book-to-market ratio (call it b/m), yearly profitability value (profit) and yearly investment value .

    its methodology and what I want to do is:
    • Construct the 5 factors as 2x3 using 6 equally weighted portfolios formed on size and B/M, the 6 equally weighted portfolios formed on size and profits and the 6 equally weighted portfolios formed on size and investments
    • To construct the SMB, HML, RMW, and CMA factors, I want to sort into two size and three respective B/M, profits, and investment groups each year. Big stocks are those in the top 90% yearly size, and small stocks are those in the bottom 10%. The B/M, profits, and investment breakpoints are the 30th and 70th percentiles of respective ratios for the big stocks

      SMB = average return on the nine small stock portfolios minus the average return on the nine big stock portfolios

      SMB(B/M) = 1/3 (Small value + Small Neutral + Small Growth)
      SMB(profits) = 1/3(small robust + small neutral + small weak) - 1/3(big robust + big neutral + big weak)
      SMB(investments) = 1/3(small conservative + small neutral + small aggressive) - 1/3(big conservative + big neutral + big aggressive)

      SMB = 1/3(SMBBM + SMBprofits SMBinvestments)

      HML is the average return on the two value portfolios minus the average return on the two growth portfolios

      HML = 1/2 (Small Value + Big Value)
      - 1/2 (Small Growth + Big Growth).
    RMW (Robust Minus Weak) is the average return on the two robust operating profitability portfolios minus the average return on the two weak operating profitability portfolios,

    RMW = 1/2 (Small Robust + Big Robust) - 1/2 (Small Weak + Big Weak).

    CMA (Conservative Minus Aggressive) is the average return on the two conservative investment portfolios minus the average return on the two aggressive investment portfolios,

    CMA = 1/2 (Small Conservative + Big Conservative) - 1/2 (Small Aggressive + Big Aggressive)



    So, basically those are want I want to do.

    Now I compute those manually although I use excel, this is really a huge amount of workload, so tired to do this. I am still in step 1 at first stage. Is anyone interesting in telling me how to achieve this through STATA?



    My data looks like the following:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long firmid double year float(size BM profits investments)
     5047 1966  8.989434  .2758487  .3733373  8.487084
     5597 1966  5.670904  .4619963  .4015927  5.138976
     6081 1966  6.936917 1.0625646 .24965106  7.491935
     8551 1966 4.0239954  .8555347 .18384364 4.5174313
    10983 1966  6.872267  .4317856 .28234044   6.95292
     1078 1967  6.442712   .310929 .29705524   5.66608
     1209 1967  5.308663 .55467165  .3036453  5.754158
     1397 1967 3.7776885 1.0129733 .25924754 4.4986978
     1414 1967  6.807433  .7044064  .3161646  7.118988
     2435 1967  5.256106  .4477937 .27640146  4.975636
     2991 1967  8.531097  .7736171  .1569048  8.577299
     3170 1967  6.483671  .4308351  .3398067  6.243779
     4040 1967    6.4163 .29091993 .28505445   5.44975
     4060 1967   7.87118  .3560086  .3340697  7.555172
     4087 1967  8.898063 .29654956   .379469  8.029791
     4199 1967  6.192754  .6145301 .29132837  6.272122
     4839 1967  8.675532  .7835172 .09970196  8.983038
     5047 1967  9.070559 .26935583  .3665313  8.584328
     5071 1967  6.484484  .3231619  .3719541  6.224756
     5125 1967 4.7162895  .3866479  .3758476 4.3670654
     5568 1967  5.660178  .8484411   .240282   6.27702
     5597 1967  5.692617  .4740874  .3313259  5.329094
     6104 1967  7.197984  .7738066 .18868434   7.29295
     6730 1967  7.456137 .16159034  .3755758  5.920237
     7063 1967   5.15637 .26193228   .331632  4.778552
     7739 1967  5.694016   .882827  .1861031  5.865901
     8215 1967  6.747763  .5122795 .20208962  6.915426
     9667 1967  5.605176  .7082593 .20257004  5.682899
    10190 1967  4.293953  .3946872  .3932487 4.2696977
    10519 1967  7.219262 .21573205  .4930443  6.506766
    10857 1967  7.993703   .562075 .29287618  8.035376
    10983 1967  6.884759 .47122255  .3176695  7.123189
     1045 1968   6.56291 .53647876  .3242966   7.25734
     1078 1968   6.83005 .23176427   .329141  5.844703
     1209 1968  5.288413  .6295648  .3002278  5.743644
     1397 1968 4.0297947  .8419294  .2451539  4.646312
     1414 1968  6.914986  .6691056  .3079258  7.198258
     1794 1968  6.853618  .3208851 .38759765  6.602352
     2316 1968   6.87217  .6346655 .17327642  6.930593
     2435 1968  5.258457  .4910951   .303345  5.046002
     2991 1968  8.670271  .7223451  .1528875  8.660357
     3170 1968  6.587067  .4135994  .3230288  6.275327
     3835 1968  6.754664  .7671866 .16304463  7.227482
     4040 1968  6.289933  .3539621 .27653322  5.531411
     4060 1968  7.765576  .4281658  .3223285  7.745955
     4087 1968  8.941022 .30126455  .4455932   8.09843
     4199 1968   6.49559  .5343718  .3397161  6.434065
     4503 1968  9.735607 .58286905 .28414568  9.728324
     5047 1968  9.048331 .29319733  .3519227  8.655871
     5071 1968  6.403985  .4654331  .3496339  6.433583
     5125 1968  5.163025 .29296684 .41898045  4.514337
     5568 1968  6.004989  .6652396 .22293574  6.395762
     5597 1968  5.909685   .397268  .3373649  5.337442
     6081 1968  6.925948 1.1405088  .1774337  7.550753
     6104 1968  7.403625  .6520171 .21070223  7.446345
     6502 1968  6.122864  .6175537  .3209695  6.379614
     7063 1968  5.798007 .17223245  .3434258  5.161076
     7435 1968 8.6443615   .151911  .4344559  7.058672
     7739 1968  6.068147  .6553814  .1894745  5.974064
     8214 1968  6.346857  .3908263 .26125008  5.859076
     8215 1968  7.060985  .4767436  .2342857  7.057726
     8543 1968  6.565828  .4099832  .3465899   6.66772
     8551 1968  4.634445  .6372877  .2095334  4.910447
     8762 1968  8.278703 .28181222  .3403535  7.385098
     9667 1968  5.778897   .654312 .20084496  5.781052
    10016 1968  5.217306  .6595056  .2044608  5.192401
    10190 1968 4.5900917  .3210852  .3607563  4.368181
    10519 1968  7.101638 .27352118  .5740599  6.793132
    10581 1968  6.056965  .7176358 .25971824  5.873525
    10795 1968  6.674854  .6955235 .29122746  7.493745
    10857 1968  7.914267  .6217688 .29159674   8.07359
    10983 1968  6.676416  .6343378 .33977845  7.213621
    11228 1968  4.919917  .6921756 .26839763  5.114395
     1045 1969  6.435575  .6466864  .3062931  7.307067
     1078 1969   6.93961  .2261898 .32917935  5.959997
     1209 1969  5.249522  .7300214 .29689828  5.889293
     1414 1969  6.586228  .9639692 .26948836  7.223749
     1794 1969   6.55702  .4998141  .3403229  6.741006
     2086 1969  6.690217 .12834859  .1935287  5.320162
     2403 1969  7.688845  .1527779  .4225672  6.407136
     2435 1969  5.496543 .42672575  .3102272  5.148081
     3170 1969  6.473836  .4796143  .2932108    6.3637
     3851 1969  6.531176  .3300984 .55810875  6.452467
     3946 1969   5.27388 .22431025  .3528176  4.302875
     4040 1969  6.164437  .4266514  .2653891  5.604374
     4060 1969  7.637028  .5209601  .3180288  7.870844
     4199 1969  6.543495  .5860513  .3416991  6.600559
     4390 1969  3.757255  .3254207   .389152 3.2712026
     5125 1969  5.161422 .38208315  .3923619 4.7048163
     5568 1969  6.130436  .7346607 .20958787  6.506594
     5597 1969  5.682165  .4926932  .2299529   5.32742
     6066 1969 10.632246  .1273093  .5481468  8.907877
     6104 1969  7.405817  .6744854  .2280687  7.542972
     6502 1969  5.925242  .8261876  .3139357  6.540047
     7063 1969  5.966887 .19922693  .2939452  5.504482
     7435 1969  8.723453  .1600976  .4204961  7.203113
     7739 1969   5.85014  .8340432  .1781812  6.015355
     8214 1969  6.457884  .3805804   .289143  6.022532
     8215 1969   6.90955  .5869568  .2858093  7.130624
     8479 1969  7.069248 .25319684  .3638099  6.317575
    end


    crossposted: https://quant.stackexchange.com/ques...ios-with-stata
    Last edited by Bram Staniksen; 05 May 2017, 05:47.
Working...
X