I'm ok with the notions of component and marginal VaR but can't retrieve results from marginal. First what is the PortfolioVaR with the portfolio_method="marginal" ? Except the sign, the 2 figures I get from these functions for PortfolioVaR are differents : VaR(tsdata,method="gaussian",portfolio_method="marginal") VaR(tsdata,method="gaussian",portfolio_method="component")$VaR Second -and it is maybe be related - how is the marginal VaR computed ? I tried the following but the result is different from the function (here it is the 5th marginal) : VaR(tsdata,method="gaussian",portfolio_method="component")$VaR-VaR(tsdata[,-5],method="gaussian",portfolio_method="component")$VaR Many thanks for any helpful comment, PS : tsdata is any valid timeSeries. -- View this message in context: http://r.789695.n4.nabble.com/Value-at-risk-tp3516991p3609051.html Sent from the Rmetrics mailing list archive at Nabble.com.
Value-at-risk
4 messages · Brian G. Peterson, sadako
On Sun, 2011-06-19 at 03:19 -0700, sadako wrote:
I'm ok with the notions of component and marginal VaR but can't retrieve results from marginal. First what is the PortfolioVaR with the portfolio_method="marginal" ? Except the sign, the 2 figures I get from these functions for PortfolioVaR are differents : VaR(tsdata,method="gaussian",portfolio_method="marginal") VaR(tsdata,method="gaussian",portfolio_method="component")$VaR
Marginal and component VaR *are* different. So I'm not sure I understand what you're asking, entirely. Component VaR is a coherent risk measure per Artzner. The component risks will add up to the univariate VaR of the entire portfolio. The univariate portfolio VaR is given in the $VaR slot you reference in your code. The additive measures are available two different ways, in the $contribution slot (which will add up to the univariate portfolio VaR) and in the $pct_contrib_VaR slot which will add up to 1(100%)
Second -and it is maybe be related - how is the marginal VaR computed ?
Marginal VaR is the difference between the univariate portfolio VaR of a a portfolio with the instrument in question and the VaR of the portfolio without that instrument. It is not guaranteed to add up to anything. Frankly, I think it is a useless measure *unless* you are comparing two otherwise similar instruments for inclusion in a portfolio, and want to see which of those two instruments would add less risk to the portfolio "at the margin".
I tried the following but the result is different from the function (here it is the 5th marginal) : VaR(tsdata,method="gaussian",portfolio_method="component")$VaR-VaR(tsdata[,-5],method="gaussian",portfolio_method="component")$VaR
Component VaR and marginal VaR aren't interchangeable, as described above, and as described in the documentation. simple subtraction doesn't work, because the portfolio (capital) needs to be redistributed. The weighting factor is weightfactor = sum(weightingvector)/sum(t(weightingvector)[, -column]) you can see the code with: PerformanceAnalytics:::VaR.Marginal
Many thanks for any helpful comment,
I hope this helps,
- Brian
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock
braverock wrote:
On Sun, 2011-06-19 at 03:19 -0700, sadako wrote:
I'm ok with the notions of component and marginal VaR but can't retrieve results from marginal. First what is the PortfolioVaR with the portfolio_method="marginal" ? Except the sign, the 2 figures I get from these functions for PortfolioVaR are differents : VaR(tsdata,method="gaussian",portfolio_method="marginal") VaR(tsdata,method="gaussian",portfolio_method="component")$VaR
Marginal and component VaR *are* different. So I'm not sure I understand what you're asking, entirely. Component VaR is a coherent risk measure per Artzner. The component risks will add up to the univariate VaR of the entire portfolio. The univariate portfolio VaR is given in the $VaR slot you reference in your code. Marginal VaR is the difference between the univariate portfolio VaR of a a portfolio with the instrument in question and the VaR of the portfolio without that instrument.
Actually I didn't mean to compare marginal and component : I just use the portfolio_method="component" to get the univariate VaR of the portfolio ($VaR slot). I have the same number using calculation like qnorm(0.95,0,1)*sqrt(t(wghts)%*%var(tsdata)%*%wghts)-t(wghts)%*%colMeans(tsdata). I would have expect to have the same number for this univariate portfolio VaR in the "PortfolioVaR" column of VaR(...,portfolio_method="marginal"), - all other parameters being equal - but this is not the case. Both should represent the univariate portfolio VaR aren't they ?
I tried the following but the result is different from the function (here it is the 5th marginal) : VaR(tsdata,method="gaussian",portfolio_method="component")$VaR-VaR(tsdata[,-5],method="gaussian",portfolio_method="component")$VaR
Component VaR and marginal VaR aren't interchangeable, as described above, and as described in the documentation. simple subtraction doesn't work, because the portfolio (capital) needs to be redistributed. The weighting factor is weightfactor = sum(weightingvector)/sum(t(weightingvector)[, -column])
Nota : here again I just use the $VaR slot of component to get access to the univariate VaR of portfolio. I think I got the weight factor right implicitly since I don't set any special weights vectors : the VaR functions sets these weights equally in both members of my equation. Assume I'm working with 5 assets : - the univariate VaR of the portfolio : VaR(tsdata,method="gaussian",portfolio_method="component")$VaR is computed with default weights=c(0.2,0.2,0.2,0.2,0.2) - the VaR of the portfolio without the asset 5 : VaR(tsdata[,-5],method="gaussian",portfolio_method="component")$VaR is computed with equally-weighted default weights=c(0.25,0.25,0.25,0.25). These are indeed the weights of the 5-assets portfolio taking into account the weight factor of sum(weightingvector)/sum(t(weightingvector)[, -5])=1.25 Marginal VaR is the difference between the univariate portfolio VaR of a
a portfolio with the instrument in question and the VaR of the portfolio without that instrument.
So with no weight specification, the stricto-sensu calculation : VaR(tsdata,method="gaussian",portfolio_method="component")$VaR-VaR(tsdata[,-columnAsset],method="gaussian",portfolio_method="component")$VaR should work or this is non-sense ?
you can see the code with: PerformanceAnalytics:::VaR.Marginal
I'm having a look, maybe the difference stems from the application of Return.portfolio in the marginal case...
Many thanks for any helpful comment,
I hope this helps,
- Brian
It did, thank you very much Brian ! -- View this message in context: http://r.789695.n4.nabble.com/Value-at-risk-tp3516991p3609482.html Sent from the Rmetrics mailing list archive at Nabble.com.
sadako wrote:
you can see the code with: PerformanceAnalytics:::VaR.Marginal
I'm having a look, maybe the difference stems from the application of Return.portfolio in the marginal case...
I think we don't get the same univariate portfolio VaR with the two portfolio_method "marginal" and "component" because of : - in PerformanceAnalytics:::VaR.Marginal, the Return.portfolio are calculated without the optional argument geometric (geometric=FALSE would eventually match the stdev I compute). - in PerformanceAnalytics:::VaR.Marginal, when calling the portfolio_method="single" to compute the univariate portfolio VaR, we end up in the PerformanceAnalytics:::VaR.Gaussian function. This function uses the PerformanceAnalytics:::centeredmoment function, which uses the mean function. This does not give the same variance as stdev for instance since there's not the ajustement of the estimator (division by n-1 instead of n if data set has n observations). If we set m2 = centeredmoment(r, 2)*dim(r)[1]/(dim(r)[1]-1), it looks ok. With these two modifications, I have the impression the univariate portfolio VaR computed from portfolio_method="marginal" and portfolio_method="component" are consistant. -- View this message in context: http://r.789695.n4.nabble.com/Value-at-risk-tp3516991p3609604.html Sent from the Rmetrics mailing list archive at Nabble.com.