Skip to content

Calculating Portfolio Standard deviation

3 messages · Amelia Vettori, Joshua Wiley, Patrick Burns

#
Dear Amelia,

If you have the actual data you should be able to use the variance covariance matrix to simplify this

Vdat <- cov(prices_df)

sum(diag(Vdat)) + 2*Vdat[upper.tri(Vdat)]

By using covariances instead of correlations you do not need to multiply by he standard deviations and by using variances there's no need to square. The only trick would be adding your weights back in.  See ?diag and ?upper.tri and ?vcov for relevant documentation.

Cheers,

Josh
On Jan 10, 2011, at 0:26, Amelia Vettori <amelia_vettori at yahoo.co.nz> wrote:

            
#
That should be the variance matrix
of returns, not prices.  (I have a
blog post on this already written
that will be published later this week.)
On 10/01/2011 09:05, Joshua Wiley wrote: