Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Compute portfolio variance


From   Alberto Dorantes <[email protected]>
To   [email protected]
Subject   Re: st: Compute portfolio variance
Date   Wed, 12 Sep 2012 21:49:00 -0500

Hi André.
  It is hard to see how you are using your dataset to compute your
portfolio variance. For example, I do not see where are the weights in
your dataset.

If you had something like a set of vectors (a matrix) of different
combinations of portfolio weights for N stocks, and also if you have
the Var-Cov Matrix (or the historical return data of each of the N
stocks, you can easily compute the Var-Cov matrix), then it is  simple
to compute all portfolio variances in only one Matrix multiplication.
It is faster to use MATA for this. MATA is a computer language that
can be invoked from Stata.

In matrix notation, the variance of a portfolio is:
Var(Portfolio) = w' * COV * w
Where COV is the Var-Covar matrix of the N returns considered in the
portfolio, and w can be either a vector or a set of vectors (matrix)
of different portfolio combinations.
If N is too big, you can have problems with Mata to do the matrix
multiplication, but you can use a loop to do N matrix multiplications
using w as a different vector each time.

Let me know if you want to compute different variance of potfolio
combinations, and I can share with you a Mata code I have for doing
this.

I hope this help... Alberto Dorantes



2012/9/10 André Gyllenram <[email protected]>:
> Hello,
>
> I want to compute the portfolio variance for each individual in every time-period.
>
> Portfolio variance = (weight(1)^2*variance(1) + weight(2)^2*variance(2) + 2*weight(1)*weight(2)*covariance(1,2)
>
> My data-material is in this format:
>
>
>
>
>
> individual  date                 STOCK    varISIN1    varISIN2   ...   varISIN199    corrSTOCK1STOCK2  corrSTOCK1STOCK3   ...   corrSTOCK99STOCK198
> 1          20000101              stock1   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 1          20000101              stock2   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 1          20000102              stock3   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 1          20000102              stock77  .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 1          20000103              stock1   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000101              stock100 .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000101              stock3   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000101              stock2   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000102              stock66  .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000103              stock3   .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
> 2          20000103              stock22  .3333333    450.3333         30.33333     .7073684          -.5765567                .1696948
>
>
>
>
> The problem is that every individual do not own every stock. I also have a very large number of individuals so I cannot compute the portfolio variance for every individual and date manually.
>
>
> Does anyone have an idea how to do this?
>
> Kind regards
> André Gyllenram
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index