Announcement

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

  • Computing daily value weighted average portfolio returns

    I am trying to compute value weighted average daily portfolio returns for a portolio, but am not sure how to correctly code this

    my data looks the following:
    date company companyreturn marketcap2016 marketreturn industry eventdummy Market weighted return (not yet created)
    1 x 1 300 3 d 0 UU
    2 x 2 300 2 d 1 VV
    3 x 1 300 3 d 0 WW
    1 y 0 200 3 e 0 UU
    2 y 3 200 2 e 1 VV
    3 y 1 200 3 e 0 WW
    1 z -1 150 3 f 0 UU
    2 z -3 150 2 f 1 VV
    3 z 5 150 3 f 0 WW
    How can I create the last column "Market weighted return (not yet created)"

    Thereafter, I would like to reduce the table size to the following
    date marketreturn eventdummy Market weighted return (not yet created)
    1 3 0 UU
    2 2 1 VV
    3 3 0 WW
    This i expect to do the following:

    duplicates drop date marketreturn eventdummy marketweightedreturn
    drop company companyreturn marketcap2016 industry.


    I am just a bit lost on how to first create the market weighted return (that consists of the daily value(market cap) weighted average return for the portfolio that consists of all the companies in the sample


    Could you help me with this?
    Last edited by ties jongen; 01 May 2021, 11:46.

  • #2
    I am not sure how to read the data that you are showing -- what are those returns that are 1,3,5, -3, etc...

    But you can calculate weighted averages with my function -egen, wmean()-

    From within Stata type

    Code:
     ssc install _gwmean
    and then to calculate the weighted average of return for each date:
    Code:
    egen meanret = wmean(ret), by(date) weights(market_cap)

    Comment


    • #3
      The returns are just an example; in my real data they are shown as decimals eg; 0.0324645 being around 3.2%


      I will look at it now, thank you for the fast response, again! :D

      Comment


      • #4
        It worked, thank you so much for the help!

        Comment

        Working...
        X