Announcement

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

  • #31
    I know that I'm bothering you, but can you help me and modify your last code so I can change the sample period and the portfolios so I can choose for example:
    // GO TO LONG LAYOUT rename (FFS* RISK*) return= reshape long return, i(mdate) j(portfolio) string capture program drop one_period program define one_period tsset mdate, delta(3) gen delta = N_cf - N_dr summ delta local denom = r(Var) corr return N_cf, cov local cf1 = r(cov_12) corr return L1.N_cf, cov local cf2 = r(cov_12) gen beta_cf = (`cf1' + `cf2')/`denom' corr return N_dr, cov local dr1 = r(cov_12) corr return L1.N_dr, cov local dr2 = r(cov_12) gen beta_dr = (`dr1' + `dr2')/`denom' drop delta exit end runby one_period, by(year portfolio) once with FFS portfolios alone, and once with RISK portfolios , I have been trying but the reshape won't work with me.
    your highly is highly appreciated
    Thank you

    Comment


    • #32
      Please repost your question so that the code in question is readable--or if you are referring here to the code in #27, just say that. And explain what you mean when you refer to changing the sample period and portfolios. And provide current example data. If the reshape command "won't work" it is almost certainly because there is something different about the data you are working with. By the way, never say something "won't work." There are many ways in which something might fail to work, and if somebody is to help you, you must explain exactly what is going wrong! That means describing exactly what Stata did when you tried the command, or, better, still, showing the output.

      Comment


      • #33

        Yes, I'm referring to code #27, I'm sorry I didn't explain it well, this code works perfectly, however, I was trying to reshape and calculate the Betas for each type of the portfolios, as you can see, there are 2 types of portfolios, BEME or the defined FFS* portfolios and the other type is the RISK* portfolios, what I've been trying to do is to do the exact same thing for each type of the portfolios alone and I want to be able to do that for two sub periods Early period (1929:m1-1963:m6) and the modern period (1963:m7-2001:m12) because I have to present these estimated beta for each type of a portfolios by reshaping again into a table Thank you so much in advance

        Comment


        • #34
          I'm afraid I still don't understand what you want to do. The code in #27 produces separate results for each portfolio in each year. It sounds like you now want to somehow aggregate the results for two different types of portfolios and two different eras. But you don't explain how you want to combine the results of each separate BEME portfolio into a summary number for all BEME portfolios, nor for the RISK portfolios. Similarly, you don't explain how you want to combine the results for each individual year into those two eras. Also, and harder to deal with, you don't explain how you want 1963 handled. Your definition of early and modern periods splits at the middle of 1963, but you don't have separate results for early 1963 and late 1963: you have results by year. So, here is my best guess for what you want to do:

          Code:
          gen portfolio_type = "RISK" if strops(portfolio, "RISK")
          replace portfolio_type = "BEME" if strops(portfolio, "BM")
          gen era = "Early" if inrange(mdate, tm(1929m1), tm(1963m6))
          replace era = "Modern" if inrange(mdate, tm(1963m7), tm(2001m12))
          table portfolio_type era, c(?????????????????????)
          Read -help table- and replace the question marks by appropriate code for whatever it is you want to calculate for each combination of portfolio andtype and era.

          If that's not it, post back and show (don't just describe in words, but show visually as well) what you want to do.

          Comment


          • #35
            Thank you so much, this is exactly what I want to do, to aggregate the results for two different types of portfolios and two different eras. however, I want a table that shows the clusters of the corresponding returns(clustered into 5 clusters) for each type of portfolio and and present accordingly the estimated betas for each cluster
            so I would have a nice table showing my estimated betas. I tried to replace the last line of code by ((bysort portfolio_type :table beta_cf return)), it didn't work well for me.
            can you tell me how to do it?

            Comment


            • #36
              I tried to replace the last line of code by ((bysort portfolio_type :table beta_cf return)), it didn't work well for me.
              can you tell me how to do it?

              If you just want results by portfolio_type alone, there is no need to use -table. You can get that more easily with:

              Code:
              tabstat beta_cf return, by(portfolio_type)
              -table- is more suitable when you want a cross-classification, for example, portfolio_type and era, as in #34. Actually -table- can even do a three or four-way cross classification as well, though nothing you have described so far suggests you will need that capability.

              Comment


              • #37
                no what I need is 4 tables:
                one present my estimated beta_cf and the returns corresponds to BEME portfolios and another table for the RISK portfolios
                and another two for beta_dr . like this :

                TableHeadings -> Coulums{{"ME-low", "ME-2", "ME-3", "ME-4",
                "ME-5"},Rows {"BV-low", "BV-2", "BV-3", "BV-4", "BV-5"}}], and so inside the table is the estimations of betas, accordingly:
                Beta_cf ME-low ME-2 ME-3 ME-4 ME-high
                BV-small
                BV-2
                BV-3
                BV-4
                BV-Large

                Comment


                • #38
                  Sarah,

                  You have to remember that I can't read your mind. There are no references to anything like "ME-low" or "BV-3" in the data examples you have posted and I have no idea what they mean or where they are supposed to come from. Maybe their meaning would be obvious to somebody who works in finance, but I've never heard of them. This is a multi-disciplinary forum, and you should only use jargon and abbreviations that would be understood by anybody with a college education, regardless of their discipline or profession. Presumably they are values of variables you have not revealed. Also, when you say you want to present Beta_cf in the table, you haven't explained what that means: unless there are only 25 observations in your data set (which I already know is not the case) there will be more than one value of Beta_cf in each combination of BV_whatever and ME_whatever. So what do you want to put in the cell: the mean value of beta_cf among those? The median? The biggest? The smallest? The chronologically last? What?

                  But here's the general scheme of how to do this. Let's imagine that the values ME-low through ME-high are values of a variable called me_level. Similarly, let's assume that BV-small through BV-Large are the values of a variable called bv_level. Then the tables you want will come from commands that look like this:

                  Code:
                  table bv_level me_level, c(??????????????) by(portfolio_type)
                  
                  table bv_level me_level, c(XXXXXXXXXXXXXXXXXXX) by(portfolio_type)
                  where ???????????? is going to be some specification involving beta_cf, and XXXXXXXXXXXX is going to be some specification involving beta_dr.

                  See -help table- to learn how to specify the statistics of beta_cf and beta_dr that you actually want. You may also want to use the -format()- option to control how many decimal places are shown.

                  Comment


                  • #39
                    I'm so sorry for the confusion that I put you in,
                    Regarding the ((unless there are only 25 observations in your data set )) -->YES, there are 25 BEME portfolios and 20 RISK portfolios (the total is 45 portfolios), so the estimated betas should be 25 estimates for each corresponding BEME portfolios, and 20 estimates correspond to the 20 RISK portfolios that's why I wanted previously to aggregate the results for two different types of portfolios

                    I'm so sorry again

                    Comment


                    • #40
                      these are the BEME portfolios: 25 portfolios, and hence there will be 25 estimated betas for each corresponding portfolios:
                      FFS1BM1 FFS1BM2 FFS1BM3 FFS1BM4 FFS1BM5
                      FFS2BM1 FFS2BM2 FFS2BM3 FFS2BM4 FFS2BM5
                      FFS3BM1 FFS3BM2 FFS3BM3 FFS3BM4 FFS3BM5
                      FFS4BM1 FFS4BM2 FFS4BM3 FFS4BM4 FFS4BM5
                      FFS5BM1 FFS5BM2 FFS5BM3 FFS5BM4 FFS5BM5

                      Comment


                      • #41
                        OK, but which of these portfolios are in which BV level and in which ME level. I suppose it relates in someway to the numbers following FFS and BM in the portfolio names, but what is what?

                        You have to keep in mind that you are trying to give very concrete, detailed instructions to somebody who has no idea what anything your data set means! Everything has to be made explicit. Gaps cannot be filled in. (I'm referring here to the computer, but also to myself.)

                        Comment


                        • #42
                          I'm so sorry, the BE level is the part that follows the BM (or the columns) and the ME part that follows the FFS (or the rows)

                          Comment


                          • #43
                            All right. But you still haven't shown example data, so I still don't know what you're working from. Be sure to use -dataex-. Show an example of the data as it looks right before the point where you want to create these tables.

                            If you are running version 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                            When asking for help with code, always show example data. When showing example data, always use -dataex-.
                            Last edited by Clyde Schechter; 29 Mar 2020, 22:13.

                            Comment


                            • #44
                              ----------------------- copy starting from the next line -----------------------
                              Code:
                              * Example generated by -dataex-. To install: ssc install dataex
                              clear
                              input int mdate str7 portfolio long Date double(R_Me TY PE VS EtR_Me N_dr N_cf Rrf return) float date int year byte period float(beta_cf beta_dr beta)
                              -372 "FFS1BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0294 -372 1929 1     .05924752  .3262584  .3855059
                              -372 "FFS1BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0725 -372 1929 1    -.06193411  .4790082 .41707405
                              -372 "FFS1BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0359 -372 1929 1     .00982766  .4029027  .4127304
                              -372 "FFS1BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0342 -372 1929 1   -.005368913  .5225681  .5171992
                              -372 "FFS1BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356         .045 -372 1929 1   -.019985776  .5527377  .5327519
                              -372 "FFS2BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0263 -372 1929 1   .0032415094  .6284044  .6316459
                              -372 "FFS2BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0154 -372 1929 1   -.020822156  .5552655  .5344433
                              -372 "FFS2BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0048 -372 1929 1   .0042878776  .4580335  .4623214
                              -372 "FFS2BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0119 -372 1929 1      .0352345  .3948077  .4300422
                              -372 "FFS2BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0098 -372 1929 1 -.00009482048  .5912477 .59115285
                              -372 "FFS3BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0085 -372 1929 1    .011321996  .6915067  .7028287
                              -372 "FFS3BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356         .061 -372 1929 1    .001216485  .5897798 .59099627
                              -372 "FFS3BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0185 -372 1929 1    .009671984 .29456446  .3042364
                              -372 "FFS3BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0347 -372 1929 1   -.011182434  .5506634   .539481
                              -372 "FFS3BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0294 -372 1929 1     .01597782 .55004495 .56602275
                              -372 "FFS4BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0387 -372 1929 1     .02939587  .7167775  .7461734
                              -372 "FFS4BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0368 -372 1929 1   -.012668965 .55318886  .5405199
                              -372 "FFS4BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0458 -372 1929 1    .015964294  .4676221  .4835864
                              -372 "FFS4BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0053 -372 1929 1   -.007218322  .4046834 .39746505
                              -372 "FFS4BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0429 -372 1929 1     .03732603  .5744621  .6117882
                              -372 "FFS5BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0578 -372 1929 1    .036220156  .6428615  .6790817
                              -372 "FFS5BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0972 -372 1929 1    .010005615  .7341053  .7441109
                              -372 "FFS5BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0298 -372 1929 1    .008297929  .5592648  .5675627
                              -372 "FFS5BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0526 -372 1929 1    .003646429   .440443  .4440894
                              -372 "FFS5BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0064 -372 1929 1   .0008559166  .3263886  .3272445
                              -372 "RISK1"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .098431561 -372 1929 1    .028652295  .7569353  .7855876
                              -372 "RISK10"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0061030286 -372 1929 1    .062652744   .727827  .7904797
                              -372 "RISK11"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .098908375 -372 1929 1     .02620109  .6222121  .6484131
                              -372 "RISK12"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .062109543 -372 1929 1    -.03625267   .666667  .6304144
                              -372 "RISK13"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .093045235 -372 1929 1    .013913565  .6706531  .6845667
                              -372 "RISK14"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .03877791 -372 1929 1    .014974905   .745456  .7604309
                              -372 "RISK15"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   -.01948815 -372 1929 1     .05293516  .7823805  .8353156
                              -372 "RISK16"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .04721912 -372 1929 1      .0355169  .5424857 .57800263
                              -372 "RISK17"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .040854409 -372 1929 1   -.004129561  .3801437  .3760142
                              -372 "RISK18"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0034716927 -372 1929 1    .024188194  .4141795  .4383677
                              -372 "RISK19"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .06832487 -372 1929 1 -.00048961496 .56538683 .56489724
                              -372 "RISK2"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .053369589 -372 1929 1     -.0224927  .4826655  .4601728
                              -372 "RISK20"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .15243614 -372 1929 1     .04937126  .7318066  .7811779
                              -372 "RISK3"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .032101969 -372 1929 1    .006431182  .4661315  .4725627
                              -372 "RISK4"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .088620282 -372 1929 1    .028872114  .6427931  .6716652
                              -372 "RISK5"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .11580332 -372 1929 1    .033250034  .8001252  .8333753
                              -372 "RISK6"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .041898925 -372 1929 1    .034086682 .37238285  .4064695
                              -372 "RISK7"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0062128445 -372 1929 1    .003068335 .52689254  .5299609
                              -372 "RISK8"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .087512204 -372 1929 1     .02363682 .58461994  .6082568
                              -372 "RISK9"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .061116683 -372 1929 1    -.00983582  .7372195  .7273837
                              -360 "FFS1BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247       -.0276 -360 1930 1      .8514435 1.4963475 2.3477912
                              -360 "FFS1BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247         .179 -360 1930 1      .3367208 1.5055708 1.8422916
                              -360 "FFS1BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .2242 -360 1930 1     .05446751  1.562088 1.6165555
                              -360 "FFS1BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1107 -360 1930 1     .28239095  .9522714 1.2346623
                              -360 "FFS1BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1209 -360 1930 1     .25897858  1.315512 1.5744907
                              -360 "FFS2BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1055 -360 1930 1     .07765845  1.057515 1.1351734
                              -360 "FFS2BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0759 -360 1930 1     .22215386 1.0263426 1.2484965
                              -360 "FFS2BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0733 -360 1930 1     .17719717  .9164881 1.0936853
                              -360 "FFS2BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0713 -360 1930 1      .2434063  1.102811 1.3462173
                              -360 "FFS2BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1341 -360 1930 1      .3220559 1.3403084 1.6623644
                              -360 "FFS3BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0827 -360 1930 1      .2048683  .9816515 1.1865199
                              -360 "FFS3BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1103 -360 1930 1      .3170917 1.1434426 1.4605343
                              -360 "FFS3BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0568 -360 1930 1     .17558993  .9498575 1.1254474
                              -360 "FFS3BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0634 -360 1930 1     .24670826 1.2003797  1.447088
                              -360 "FFS3BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0235 -360 1930 1      .3086642  1.372513  1.681177
                              -360 "FFS4BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0973 -360 1930 1     .23327154 1.1514522 1.3847237
                              -360 "FFS4BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0735 -360 1930 1     .22635753  .9152788 1.1416364
                              -360 "FFS4BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0578 -360 1930 1     .13564633  .8470545  .9827009
                              -360 "FFS4BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0392 -360 1930 1     .22174554  .9943134  1.216059
                              -360 "FFS4BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0352 -360 1930 1      .3222606 1.2576398 1.5799004
                              -360 "FFS5BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0675 -360 1930 1     .21648957 1.0605837 1.2770733
                              -360 "FFS5BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0582 -360 1930 1     .17482665  .9223513  1.097178
                              -360 "FFS5BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0144 -360 1930 1     .12300026    .95253 1.0755303
                              -360 "FFS5BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0457 -360 1930 1     .08322594   .842245  .9254709
                              -360 "FFS5BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247       -.0093 -360 1930 1      .0595389  .7976518  .8571907
                              -360 "RISK1"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247 -.0017166322 -360 1930 1     .14502192  .8435753  .9885972
                              -360 "RISK10"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .099690376 -360 1930 1      .2652537 1.4115243  1.676778
                              -360 "RISK11"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .054981765 -360 1930 1     .17238738   .856903 1.0292904
                              -360 "RISK12"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .058936974 -360 1930 1      .2021969  .9037679 1.1059649
                              -360 "RISK13"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .037711523 -360 1930 1     .19930057  .8474494   1.04675
                              -360 "RISK14"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .093524578 -360 1930 1     .27839682 1.1880533   1.46645
                              -360 "RISK15"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .088494497 -360 1930 1       .381925 1.6126454 1.9945704
                              -360 "RISK16"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .010481391 -360 1930 1     .08959346  .7620437  .8516371
                              -360 "RISK17"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .019530484 -360 1930 1    .063040785  .7007203  .7637611
                              -360 "RISK18"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .040227866 -360 1930 1     .15270185  .7582238  .9109257
                              -360 "RISK19"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .069703499 -360 1930 1       .211524 1.0842286 1.2957526
                              -360 "RISK2"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .038348348 -360 1930 1      .0975077  .8845042  .9820119
                              -360 "RISK20"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .092581748 -360 1930 1      .3060017 1.4533845 1.7593862
                              -360 "RISK3"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .039177107 -360 1930 1     .29500562  .9773009 1.2723064
                              -360 "RISK4"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .053244606 -360 1930 1      .2137086 1.1145675  1.328276
                              -360 "RISK5"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247    .08175016 -360 1930 1      .3345693 1.5580887  1.892658
                              -360 "RISK6"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .057623705 -360 1930 1     .13980031  .5836796  .7234799
                              -360 "RISK7"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .031550058 -360 1930 1     .03155405  .6354066  .6669606
                              -360 "RISK8"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .054729526 -360 1930 1      .2091765  .7284901  .9376665
                              -360 "RISK9"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247     .0782001 -360 1930 1      .2264739 1.1742008 1.4006747
                              -348 "FFS1BM1" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752       -.2396 -348 1931 1     .53487426  1.496919 2.0317934
                              -348 "FFS1BM2" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752         .278 -348 1931 1      .4120084 1.8344772 2.2464857
                              -348 "FFS1BM3" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752       -.0638 -348 1931 1     .51941764  2.202763  2.722181
                              -348 "FFS1BM4" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1587 -348 1931 1     .53789824 2.0833216   2.62122
                              -348 "FFS1BM5" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752         .207 -348 1931 1      .6080906 2.3335495   2.94164
                              -348 "FFS2BM1" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .0913 -348 1931 1      .3761408  1.270577 1.6467175
                              -348 "FFS2BM2" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1287 -348 1931 1      .3867088 1.3341855 1.7208943
                              -348 "FFS2BM3" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .0856 -348 1931 1      .3951588 1.5664396 1.9615984
                              -348 "FFS2BM4" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1513 -348 1931 1     .49635255 1.8770934  2.373446
                              -348 "FFS2BM5" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1669 -348 1931 1      .6203617 2.0933096  2.713671
                              end
                              format %tm mdate
                              format %tm date
                              ------------------ copy up to and including the previous line ------------------

                              Listed 100 out of 3285 observations
                              Use the count() option to list more

                              . Note that these are the data set after calculating the betas,
                              and also I'm using Stata 16
                              Last edited by Sarah Hussein; 30 Mar 2020, 08:49.

                              Comment


                              • #45
                                OK, at last I can give you some help. But the data are not the way you have described them. Your 25 BEME portfolios have different values for the beta variables, depending on the date. So in the code below, you will get a separate table for each month. Also, you have not provided any guidance how to assign me and bv levels to the RISK portfolios, so I have done nothing with them. I'm sure you can figure out how to do that yourself, modeling it on what I have done with the BEME portfolios.

                                Code:
                                * Example generated by -dataex-. To install: ssc install dataex
                                clear
                                input int mdate str7 portfolio long Date double(R_Me TY PE VS EtR_Me N_dr N_cf Rrf return) float date int year byte period float(beta_cf beta_dr beta)
                                -372 "FFS1BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0294 -372 1929 1     .05924752  .3262584  .3855059
                                -372 "FFS1BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0725 -372 1929 1    -.06193411  .4790082 .41707405
                                -372 "FFS1BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0359 -372 1929 1     .00982766  .4029027  .4127304
                                -372 "FFS1BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0342 -372 1929 1   -.005368913  .5225681  .5171992
                                -372 "FFS1BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356         .045 -372 1929 1   -.019985776  .5527377  .5327519
                                -372 "FFS2BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0263 -372 1929 1   .0032415094  .6284044  .6316459
                                -372 "FFS2BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0154 -372 1929 1   -.020822156  .5552655  .5344433
                                -372 "FFS2BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0048 -372 1929 1   .0042878776  .4580335  .4623214
                                -372 "FFS2BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0119 -372 1929 1      .0352345  .3948077  .4300422
                                -372 "FFS2BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0098 -372 1929 1 -.00009482048  .5912477 .59115285
                                -372 "FFS3BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0085 -372 1929 1    .011321996  .6915067  .7028287
                                -372 "FFS3BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356         .061 -372 1929 1    .001216485  .5897798 .59099627
                                -372 "FFS3BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0185 -372 1929 1    .009671984 .29456446  .3042364
                                -372 "FFS3BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0347 -372 1929 1   -.011182434  .5506634   .539481
                                -372 "FFS3BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0294 -372 1929 1     .01597782 .55004495 .56602275
                                -372 "FFS4BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0387 -372 1929 1     .02939587  .7167775  .7461734
                                -372 "FFS4BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0368 -372 1929 1   -.012668965 .55318886  .5405199
                                -372 "FFS4BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0458 -372 1929 1    .015964294  .4676221  .4835864
                                -372 "FFS4BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0053 -372 1929 1   -.007218322  .4046834 .39746505
                                -372 "FFS4BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0429 -372 1929 1     .03732603  .5744621  .6117882
                                -372 "FFS5BM1" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0578 -372 1929 1    .036220156  .6428615  .6790817
                                -372 "FFS5BM2" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0972 -372 1929 1    .010005615  .7341053  .7441109
                                -372 "FFS5BM3" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0298 -372 1929 1    .008297929  .5592648  .5675627
                                -372 "FFS5BM4" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356        .0526 -372 1929 1    .003646429   .440443  .4440894
                                -372 "FFS5BM5" 192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356       -.0064 -372 1929 1   .0008559166  .3263886  .3272445
                                -372 "RISK1"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .098431561 -372 1929 1    .028652295  .7569353  .7855876
                                -372 "RISK10"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0061030286 -372 1929 1    .062652744   .727827  .7904797
                                -372 "RISK11"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .098908375 -372 1929 1     .02620109  .6222121  .6484131
                                -372 "RISK12"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .062109543 -372 1929 1    -.03625267   .666667  .6304144
                                -372 "RISK13"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .093045235 -372 1929 1    .013913565  .6706531  .6845667
                                -372 "RISK14"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .03877791 -372 1929 1    .014974905   .745456  .7604309
                                -372 "RISK15"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   -.01948815 -372 1929 1     .05293516  .7823805  .8353156
                                -372 "RISK16"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .04721912 -372 1929 1      .0355169  .5424857 .57800263
                                -372 "RISK17"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .040854409 -372 1929 1   -.004129561  .3801437  .3760142
                                -372 "RISK18"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0034716927 -372 1929 1    .024188194  .4141795  .4383677
                                -372 "RISK19"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .06832487 -372 1929 1 -.00048961496 .56538683 .56489724
                                -372 "RISK2"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .053369589 -372 1929 1     -.0224927  .4826655  .4601728
                                -372 "RISK20"  192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .15243614 -372 1929 1     .04937126  .7318066  .7811779
                                -372 "RISK3"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .032101969 -372 1929 1    .006431182  .4661315  .4725627
                                -372 "RISK4"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .088620282 -372 1929 1    .028872114  .6427931  .6716652
                                -372 "RISK5"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356    .11580332 -372 1929 1    .033250034  .8001252  .8333753
                                -372 "RISK6"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .041898925 -372 1929 1    .034086682 .37238285  .4064695
                                -372 "RISK7"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356  .0062128445 -372 1929 1    .003068335 .52689254  .5299609
                                -372 "RISK8"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .087512204 -372 1929 1     .02363682 .58461994  .6082568
                                -372 "RISK9"   192901 .047326726 -.75 3.2885226 1.8517692  -.011840795 .093003782 -.033836261 .004583356   .061116683 -372 1929 1    -.00983582  .7372195  .7273837
                                -360 "FFS1BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247       -.0276 -360 1930 1      .8514435 1.4963475 2.3477912
                                -360 "FFS1BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247         .179 -360 1930 1      .3367208 1.5055708 1.8422916
                                -360 "FFS1BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .2242 -360 1930 1     .05446751  1.562088 1.6165555
                                -360 "FFS1BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1107 -360 1930 1     .28239095  .9522714 1.2346623
                                -360 "FFS1BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1209 -360 1930 1     .25897858  1.315512 1.5744907
                                -360 "FFS2BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1055 -360 1930 1     .07765845  1.057515 1.1351734
                                -360 "FFS2BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0759 -360 1930 1     .22215386 1.0263426 1.2484965
                                -360 "FFS2BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0733 -360 1930 1     .17719717  .9164881 1.0936853
                                -360 "FFS2BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0713 -360 1930 1      .2434063  1.102811 1.3462173
                                -360 "FFS2BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1341 -360 1930 1      .3220559 1.3403084 1.6623644
                                -360 "FFS3BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0827 -360 1930 1      .2048683  .9816515 1.1865199
                                -360 "FFS3BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .1103 -360 1930 1      .3170917 1.1434426 1.4605343
                                -360 "FFS3BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0568 -360 1930 1     .17558993  .9498575 1.1254474
                                -360 "FFS3BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0634 -360 1930 1     .24670826 1.2003797  1.447088
                                -360 "FFS3BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0235 -360 1930 1      .3086642  1.372513  1.681177
                                -360 "FFS4BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0973 -360 1930 1     .23327154 1.1514522 1.3847237
                                -360 "FFS4BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0735 -360 1930 1     .22635753  .9152788 1.1416364
                                -360 "FFS4BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0578 -360 1930 1     .13564633  .8470545  .9827009
                                -360 "FFS4BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0392 -360 1930 1     .22174554  .9943134  1.216059
                                -360 "FFS4BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0352 -360 1930 1      .3222606 1.2576398 1.5799004
                                -360 "FFS5BM1" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0675 -360 1930 1     .21648957 1.0605837 1.2770733
                                -360 "FFS5BM2" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0582 -360 1930 1     .17482665  .9223513  1.097178
                                -360 "FFS5BM3" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0144 -360 1930 1     .12300026    .95253 1.0755303
                                -360 "FFS5BM4" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247        .0457 -360 1930 1     .08322594   .842245  .9254709
                                -360 "FFS5BM5" 193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247       -.0093 -360 1930 1      .0595389  .7976518  .8571907
                                -360 "RISK1"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247 -.0017166322 -360 1930 1     .14502192  .8435753  .9885972
                                -360 "RISK10"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .099690376 -360 1930 1      .2652537 1.4115243  1.676778
                                -360 "RISK11"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .054981765 -360 1930 1     .17238738   .856903 1.0292904
                                -360 "RISK12"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .058936974 -360 1930 1      .2021969  .9037679 1.1059649
                                -360 "RISK13"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .037711523 -360 1930 1     .19930057  .8474494   1.04675
                                -360 "RISK14"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .093524578 -360 1930 1     .27839682 1.1880533   1.46645
                                -360 "RISK15"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .088494497 -360 1930 1       .381925 1.6126454 1.9945704
                                -360 "RISK16"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .010481391 -360 1930 1     .08959346  .7620437  .8516371
                                -360 "RISK17"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .019530484 -360 1930 1    .063040785  .7007203  .7637611
                                -360 "RISK18"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .040227866 -360 1930 1     .15270185  .7582238  .9109257
                                -360 "RISK19"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .069703499 -360 1930 1       .211524 1.0842286 1.2957526
                                -360 "RISK2"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .038348348 -360 1930 1      .0975077  .8845042  .9820119
                                -360 "RISK20"  193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .092581748 -360 1930 1      .3060017 1.4533845 1.7593862
                                -360 "RISK3"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .039177107 -360 1930 1     .29500562  .9773009 1.2723064
                                -360 "RISK4"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .053244606 -360 1930 1      .2137086 1.1145675  1.328276
                                -360 "RISK5"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247    .08175016 -360 1930 1      .3345693 1.5580887  1.892658
                                -360 "RISK6"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .057623705 -360 1930 1     .13980031  .5836796  .7234799
                                -360 "RISK7"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .031550058 -360 1930 1     .03155405  .6354066  .6669606
                                -360 "RISK8"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247   .054729526 -360 1930 1      .2091765  .7284901  .9376665
                                -360 "RISK9"   193001 .050306074 -.21 3.1068586 1.7823571 -.0045525239 .033381586  .021477012 .004067247     .0782001 -360 1930 1      .2264739 1.1742008 1.4006747
                                -348 "FFS1BM1" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752       -.2396 -348 1931 1     .53487426  1.496919 2.0317934
                                -348 "FFS1BM2" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752         .278 -348 1931 1      .4120084 1.8344772 2.2464857
                                -348 "FFS1BM3" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752       -.0638 -348 1931 1     .51941764  2.202763  2.722181
                                -348 "FFS1BM4" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1587 -348 1931 1     .53789824 2.0833216   2.62122
                                -348 "FFS1BM5" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752         .207 -348 1931 1      .6080906 2.3335495   2.94164
                                -348 "FFS2BM1" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .0913 -348 1931 1      .3761408  1.270577 1.6467175
                                -348 "FFS2BM2" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1287 -348 1931 1      .3867088 1.3341855 1.7208943
                                -348 "FFS2BM3" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .0856 -348 1931 1      .3951588 1.5664396 1.9615984
                                -348 "FFS2BM4" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1513 -348 1931 1     .49635255 1.8770934  2.373446
                                -348 "FFS2BM5" 193101 .058128412  .32 2.7409704 2.1235241  -.010630567 .079554558 -.010795579 .002291752        .1669 -348 1931 1      .6203617 2.0933096  2.713671
                                end
                                format %tm mdate
                                format %tm date
                                
                                gen byte me_level = real(substr(portfolio, 4, 1)) if substr(portfolio, 1, 3) == "FFS"
                                gen byte bv_level = real(substr(portfolio, 7, 1)) if substr(portfolio, 1, 3) == "FFS"
                                
                                tabdisp me_level bv_level if !missing(me_level, bv_level), c(beta_cf) by(date) format(%4.3f)
                                
                                tabdisp me_level bv_level if !missing(me_level, bv_level), c(beta_dr) by(date) format(%4.3f)
                                Note: If what you want is a single table that combines all the months, then you have to decide how you want to combine the different values of the beta's across months. If, for example, you want a single table that averages the betas over all the months, then instead of the -tabdisp- commands shown you would use:

                                Code:
                                table me_level bv_level if !missing(me_level, bv_level), c(beta_cf) format(%4.3f)
                                
                                table me_level bv_level if !missing(me_level, bv_level), c(beta_dr) format(%4.3f)


                                Hopefully, you can fill in the rest of the details and polish the rough edges from here.

                                Comment

                                Working...
                                X