Announcement

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

  • Calculate portfolio return of decile portfolios

    Hello everybody,

    I got a dataset with the montly return of 365 stocks over 28 years. I've calculated the market beta (b_monatlich2) for the stocks and allocated the stocks into ten decile portfolios based on their betas (for each month). Now I need to calculate the monthly excess returns of this portfolios. u_m=excess return

    To get the decile Portfolios I've used astile and xtile, which gave me the same results:
    Code:
    egen beta10= xtile(b_monatlich2), by(Monat) nq(10)
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float date2 long business float(u_m beta10)
    360 251   -.003713793 1
    360 310   -.005739493 1
    360 271  -.0017437707 1
    360  17  -.0041152965 1
    360 215       -.00026 1
    360 361       -.00026 1
    360 103   -.002382601 1
    360 289   -.006916477 1
    360 291       -.00026 1
    360  29       -.00026 1
    360  68       -.00026 1
    360 365       -.00026 1
    360  24   -.005031573 2
    360 301       -.00026 2
    360  75       -.00026 2
    360 269       -.00026 2
    360 138       -.00026 2
    360 308       -.00026 2
    360  93    .014447267 2
    360  48       -.00026 2
    360 160 -.00029503205 2
    360 298  -.0039577777 2
    360 131       -.00026 2
    360  57   -.006493726 2
    360 178       -.00026 2
    360 307       -.00494 2
    360 141       -.00026 2
    360  94   -.005751215 2
    360 177   -.008883337 2
    360 175   -.005992248 2
    360 192   -.005398897 2
    end
    format %tm date2
    label values business business
    label def business 17 "amel", modify
    label def business 24 "aon", modify
    label def business 29 "aqam", modify
    label def business 48 "blhi", modify
    label def business 57 "brin", modify
    label def business 68 "center", modify
    label def business 75 "cinc", modify
    label def business 93 "coop", modify
    label def business 94 "copa", modify
    label def business 103 "cuwr", modify
    label def business 131 "ever", modify
    label def business 138 "fedr", modify
    label def business 141 "first", modify
    label def business 160 "hall", modify
    label def business 175 "hubb", modify
    label def business 177 "huma", modify
    label def business 178 "hunt", modify
    label def business 192 "jms", modify
    label def business 215 "max", modify
    label def business 251 "oge", modify
    label def business 269 "pop", modify
    label def business 271 "ppl", modify
    label def business 289 "sbd", modify
    label def business 291 "sea", modify
    label def business 298 "shwi", modify
    label def business 301 "smith", modify
    label def business 307 "sta", modify
    label def business 308 "stif", modify
    label def business 310 "suba", modify
    label def business 361 "wiso", modify
    label def business 365 "zions", modify
    Beta10 ranges from 1 to 10 for each year (over the 365 stocks). The montly portfolio should be stored in ten variables (P1 to P10).

    Thank you in advance!

  • #2
    I'm not in finance, so I don't know how the return of a portfolio relates to the returns of the individual stocks over a fixed single time period, but my instinct is that it's just the average of the individual stocks' returns. If that's the case:

    Code:
    by beta10 month, sort: egen portfolio_return = mean(u_m)
    Note: I have used "month" here as a stand-in for whatever variable you have that identifies months in your data. Based on the command you show for generating the portfolios I'm guessing that's Monat, but since you don't include it in your example data here, I'm not sure what's going on.

    Now, I don't see why you want 10 different variables for this. That sounds like spreadsheet-think to me. It will certainly make your life harder to do it this way if you are going to be doing things with these results, like comparing across portfolios, or regressing portfolio returns against some attributes of the portfolios. Nevertheless, if you have some compelling reason to split this up into ten variables:

    [code]
    forvalues I = 1/10 {
    gen P`i' = portfolio_return if beta10 == `i'
    }

    will do that.

    Comment


    • #3
      Sorry for the confusion Monat is the german word for month, I will change it to month. The code worked fine, could have thought of this myself. Thank you.
      In this case I can use the mean of the observations, as all stocks are equally weighted and the formula for portfolio return equals:

      Expected return = (w
      1
      * r
      1
      ) + (w
      2
      * r
      2
      ) + ………… + (w
      n
      * r
      n
      ) with w=weight for stock n
      I need to split it into ten variables/portfolios because based on them I will perform further analys

      Comment


      • #4
        *Expected return = (w1*r1) + (w2* r2) + ………… + (wn* rn) with w=weight for stock n

        Comment

        Working...
        X