[R-SIG-Finance] Value-at-risk

Brian G. Peterson brian at braverock.com
Fri May 20 17:36:44 CEST 2011


On Fri, 2011-05-20 at 21:08 +0530, Bogaso Christofer wrote:
> Hi,
> 
> After Emmanuel's post in R-finance and the reply from Brian, I spent few
> times on the VaR() function and on the underlying theory. Just to admit
> that, this is great. However, I don't think I could understand the theory of
> component VaR calculation, although it seems the coding within the VaR()
> function for the same is completely okay.
> 
> My problem is, how should I interpret component VaR? Having searched over
> net and after going through few materials, I understand that, I can read
> CVaR as the change of PVaR if underlying asset is removed from the
> portfolio. Here my problem of interpretation starts from! Please consider
> following hypothetical return (a zoo object, as needed for VaR())
> 
> > Ret
>                     Ret1         Ret2         Ret3          Ret4
> Ret5         Ret6         Ret7
> 2010-04-15 -0.0009783093  0.000000000 -0.003752350 -0.0006021985
> -0.012384059 -0.012539349 -0.034979719
> 2010-04-16 -0.0004805344  0.003863495  0.003752350  0.0009617784
> 0.003110422  0.003149609  0.003231021
> 2010-04-19 -0.0273642188 -0.010336009 -0.003752350 -0.0104916573
> -0.009360443 -0.009478744 -0.006472515
> 2010-04-20  0.0154788565 -0.002600782 -0.007547206 -0.0036357217
> -0.006289329 -0.006369448  0.006472515
> 2010-04-21 -0.0094613433  0.000000000  0.000000000  0.0005484261
> 0.000000000  0.000000000  0.000000000
> 2010-04-22  0.0062536421  0.000000000  0.003780723 -0.0001143766
> 0.009419222  0.009539023  0.006430890
> 2010-04-23  0.0237922090  0.015504187  0.007518832  0.0097156191
> 0.006230550  0.006309169  0.000000000
> 2010-04-26  0.0133441736  0.012739026  0.003738322  0.0049317586
> 0.018462063  0.018692133  0.012739026
> 2010-04-28 -0.0105522323  0.000000000  0.000000000 -0.0037038049
> -0.006116227 -0.006191970  0.000000000
> 2010-04-29  0.0030733546 -0.006349228 -0.011215071 -0.0071195792
> -0.003072199 -0.003110422  0.000000000
> 
> 
> I have a long-short portfolio, I want to estimate component VaR for the 2nd
> asset, using VaR() function:
> 
> 
> > WtVector <- c( -49895159,  734677735,   51037536,   -7126937, -283834066,
> -161147892,   13652772)
> > VaR(R = Ret, p = 0.05, method = "gaussian", portfolio_method =
> "component", weights = WtVector)
> $VaR
>         [,1]
> [1,] 5434285
> $contribution
>       Ret1       Ret2       Ret3       Ret4       Ret5       Ret6       Ret7
> 
> -316156.24 5211014.96  266249.91  -50021.42  260904.17  149986.52  -87692.49
> $pct_contrib_VaR
>         Ret1         Ret2         Ret3         Ret4         Ret5
> Ret6         Ret7 
> -0.058178070  0.958914480  0.048994465 -0.009204784  0.048010759
> 0.027600044 -0.016136894
> 
> This says (if my interpretation is correct) that if I remove my 1st asset
> then, portfolio VaR will increase by -316156.24 (negative sign tells to have
> hedging effect)

You're speaking of *marginal* VaR, not component VaR.

Marginal (or Incremental) VaR is the contribution of that instrument to
the VaR of the portfolio "at the margin" (this is how I keep them
straight).  Marginal VaR is not additive, it may add up to more than
100% of the total portfolio VaR.  I find it to be a relatively poor risk
measure overall, and generally don't recommend using it (there are some
exceptions that are mentioned in the documentation for the VaR
function).  Your description describes Marginal VaR, not Component VaR.

Component VaR is the *contribution* to the portfolio VaR of each
component in the portfolio.  It adds up to the value of the entire
portfolio VaR. The value returned has three slots.
$VaR # the portfolio VaR
$contribution
  the scalar contributions of each instrument, 
  this adds up to the portfolio VaR
$pct_contribution_VaR
  the percentage contributions to VaR,
  this adds up to 1
  negative numbers are diversifiers, *decreasing*
  the total portfolio VaR 

So, given that this is component VaR we're looking at, not marginal VaR,
asset 1 is your *largest diversifier*.  Removing it would be expected to
increase the portfolio VaR, as you report below.

Hopefully this clears things up...

Regards,

   - Brian

> So I recalculate the portfolio VaR without having 1st asset:
> > WtVector <- c( 0,  734677735,   51037536,   -7126937, -283834066,
> -161147892,   13652772)
> > VaR(R = Ret, p = 0.05, method = "gaussian", portfolio_method =
> "component", weights = WtVector)
> $VaR
>         [,1]
> [1,] 5849476
> $contribution
>       Ret1       Ret2       Ret3       Ret4       Ret5       Ret6       Ret7
> 
>       0.00 5987199.26  274456.46  -55685.39 -185776.60 -106798.21  -63919.72
> $pct_contrib_VaR
>         Ret1         Ret2         Ret3         Ret4         Ret5
> Ret6         Ret7 
>  0.000000000  1.023544581  0.046919839 -0.009519723 -0.031759529
> -0.018257741 -0.010927428
> 
> I am just surprised to see that, my portfolio VaR indeed ***increased!!!***
> 
> I have found that, this kind of discrepancy comes as possible non-linear
> relationship between VaR and it's constituent assets. It happens that x-y
> plot for VaR and weight for the 1st asset is highly non-linear. sign of the
> Slope changes if I move from current point (resemble to weight for 1st
> asset) to origin (i.e. no 1st asset in the portfolio.)
> 
> So My question is, how can I trust on the sign (at least) of component VaR.
> Isn't it is giving completely misleading figure? How risk managers handle
> these issue? Does the solution like:
> 1. I should include higher term of the Taylor's expansion of the portfolio
> VaR function
> 2. Do not simply trust those component VaR figures. I should completely
> re-estimate my VaR number with and without having underlying asset.
> 
> Any thoughtful point(s) will be highly appreciated.
> 
> Thanks and regards,
> 
> -----Original Message-----
> From: r-sig-finance-bounces at r-project.org
> [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Brian G. Peterson
> Sent: 12 May 2011 17:28
> To: Emmanuel Senyo
> Cc: r-sig-finance at stat.math.ethz.ch
> Subject: Re: [R-SIG-Finance] Value-at-risk
> 
> There is over 100 pages of documentation available with
> PerformanceAnalytics.
> 
> I suggest you start with 
> 
> install.packages("PerformanceAnalytics")
> #you only need to do the install the first time
> 
> require(PerformanceAnalytics)
> ?VaR  
> 
> from the R prompt.  See the examples at the bottom of the VaR documentation.
> 
> Hopefully that will get you started.  If you have trouble, you may email the
> R-SIG-Finance list or me with an example of what you're trying to do.
> Ideally, start with some publicly available data (use the edhec or managers
> data in Performanceanalytics, or use getSymbols to pull stock data from
> Yahoo or Google) so that others can replicate what you're trying to do and
> help you with code rather than vague suggestions.
> 
> Regards,
> 
>    - Brian
> 
> On Thu, 2011-05-12 at 13:47 +0200, Emmanuel Senyo wrote:
> > Dear Brian,
> > Thanks for the mail, I have now located the PerformanceAnalytics.
> > Could you please elaborate on it how I could use this package, the 
> > fact is that I am new to R, how i would like compute value at risk for 
> > prices and volumes. If I can get a sample scripts with explanation 
> > that would be very helpful to me to enable me build my own scripts.
> > Regards
> > Emma
> > 
> > On Thu, May 12, 2011 at 1:21 PM, Brian G. Peterson 
> > <brian at braverock.com> wrote:
> >         
> >         On Thu, 2011-05-12 at 12:38 +0200, Emmanuel Senyo wrote:
> >         > Dear All,
> >         > I am currently work on Value-at-risk and would like to know
> >         the package that
> >         > is helpful in this regard. It consist of three method, that
> >         is variance
> >         > covariance method, Monte carlo simulation, and Historical
> >         simulation.
> >         > Regards
> >         > Em
> >         
> >         
> >         The Gaussian and Historical methods are available in
> >         PerformanceAnalytics.
> >         
> >         You can easily use the Monte Carlo method of your choice to
> >         create a
> >         longer sample, and then use PerformanceAnalytics to calculate
> >         the VaR.
> >         
> >         There are also several bootstrap Monte Carlo methods in
> >         PerformanceAnalytics that have been contributed by Eric Zivot,
> >         but which
> >         we have not yet documented and exposed.
> >         
> >         Regards,
> >         
> >           - Brian
> >         
> >         --
> >         Brian G. Peterson
> >         http://braverock.com/brian/
> >         Ph: 773-459-4973
> >         IM: bgpbraverock
> >         
> > 
> 
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list