sum(B) would give me the weighted non-diagonal
> elements. This gives me
>
> > B
> [1] -0.4955 0.5075 -1.8950 -1.8950
>
> However, actually I should be getting
>
> -0.017778, -0.036667, -0.4955, 0.3, 0.5075, -1.8950
>
> That's because when I consider (1,2)
B[1] only once and likewise.
Kindly guide.
regards
Amelia
--- On Mon, 10/1/11, Joshua Wiley wrote:
From: Joshua Wiley
Subject: Re: [R] Calculating Portfolio Standard deviation
To: "Amelia Vettori"
Cc: "r-help@r-project.org"
Received: Monday, 10 January, 2011,
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:
Dear Amelia,
If you have the actual data you should be able to use the variance covariance
matrix to simplif
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 v
Dear R helpers
I have following data
stocks <- c("ABC", "DEF", "GHI", "JKL")
prices_df <- data.frame(ABC = c(17,24,15,22,16,22,17,22,15,19),
DEF =
c(22,28,20,20,28,26,29,18,24,21),
GHI =
c(32,27,32,36,37,37,34
5 matches
Mail list logo