Skip to content
Prev 246895 / 398506 Next

Calculating Portfolio Standard deviation

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: