# An Introoduction to Portfolio Component Conditional Value At Risk

**R – QuantStrat TradeR**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This post will introduce component conditional value at risk mechanics found in PerformanceAnalytics from a paper written by Brian Peterson, Kris Boudt, and Peter Carl. This is a mechanism that is an easy-to-call mechanism for computing component expected shortfall in asset returns as they apply to a portfolio. While the exact mechanics are fairly complex, the upside is that the running time is nearly instantaneous, and this method is a solid tool for including in asset allocation analysis.

For those interested in an in-depth analysis of the intuition of component conditional value at risk, I refer them to the paper written by Brian Peterson, Peter Carl, and Kris Boudt.

Essentially, here’s the idea: all assets in a given portfolio have a marginal contribution to its total conditional value at risk (also known as expected shortfall)–that is, the expected loss when the loss surpasses a certain threshold. For instance, if you want to know your 5% expected shortfall, then it’s the average of the worst 5 returns per 100 days, and so on. For returns using daily resolution, the idea of expected shortfall may sound as though there will never be enough data in a sufficiently fast time frame (on one year or less), the formula for expected shortfall in the PerformanceAnalytics defaults to an approximation calculation using a Cornish-Fisher expansion, which delivers very good results so long as the p-value isn’t too extreme (that is, it works for relatively sane p values such as the 1%-10% range).

Component Conditional Value at Risk has two uses: first off, given no input weights, it uses an equal weight default, which allows it to provide a risk estimate for each individual asset without burdening the researcher to create his or her own correlation/covariance heuristics. Secondly, when provided with a set of weights, the output changes to reflect the contribution of various assets in proportion to those weights. This means that this methodology works very nicely with strategies that exclude assets based on momentum, but need a weighting scheme for the remaining assets. Furthermore, using this methodology also allows an ex-post analysis of risk contribution to see which instrument contributed what to risk.

First, a demonstration of how the mechanism works using the edhec data set. There is no strategy here, just a demonstration of syntax.

require(quantmod) require(PerformanceAnalytics) data(edhec) tmp <- CVaR(edhec, portfolio_method = "component")

This will assume an equal-weight contribution from all of the funds in the edhec data set.

So tmp is the contribution to expected shortfall from each of the various edhec managers over the entire time period. Here’s the output:

$MES [,1] [1,] 0.03241585 $contribution Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.0074750513 -0.0028125166 0.0039422674 0.0069376579 0.0008077760 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.0037114666 0.0043125937 0.0007173036 0.0036152960 0.0013693293 Relative Value Short Selling Funds of Funds 0.0037650911 -0.0048178690 0.0033924063 $pct_contrib_MES Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.23059863 -0.08676361 0.12161541 0.21402052 0.02491917 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.11449542 0.13303965 0.02212817 0.11152864 0.04224258 Relative Value Short Selling Funds of Funds 0.11614968 -0.14862694 0.10465269

The salient part of this is the percent contribution (the last output). Notice that it can be negative, meaning that certain funds gain when others lose. At least, this was the case over the current data set. These assets diversify a portfolio and actually lower expected shortfall.

> tmp2 <- CVaR(edhec, portfolio_method = "component", weights = c(rep(.1, 10), rep(0,3))) > tmp2 $MES [,1] [1,] 0.04017453 $contribution Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.0086198045 -0.0046696862 0.0058778855 0.0109152240 0.0009596620 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.0054824325 0.0050398011 0.0009638502 0.0044568333 0.0025287234 Relative Value Short Selling Funds of Funds 0.0000000000 0.0000000000 0.0000000000 $pct_contrib_MES Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.21455894 -0.11623499 0.14630875 0.27169512 0.02388732 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.13646538 0.12544767 0.02399157 0.11093679 0.06294345 Relative Value Short Selling Funds of Funds 0.00000000 0.00000000 0.00000000

In this case, I equally weighted the first ten managers in the edhec data set, and put zero weight in the last three. Furthermore, we can see what happens when the weights are not equal.

> tmp3 <- CVaR(edhec, portfolio_method = "component", weights = c(.2, rep(.1, 9), rep(0,3))) > tmp3 $MES [,1] [1,] 0.04920372 $contribution Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.0187406982 -0.0044391078 0.0057235762 0.0102706768 0.0007710434 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.0051541429 0.0055944367 0.0008028457 0.0044085104 0.0021768951 Relative Value Short Selling Funds of Funds 0.0000000000 0.0000000000 0.0000000000 $pct_contrib_MES Convertible Arbitrage CTA Global Distressed Securities Emerging Markets Equity Market Neutral 0.38087972 -0.09021895 0.11632406 0.20873782 0.01567043 Event Driven Fixed Income Arbitrage Global Macro Long/Short Equity Merger Arbitrage 0.10475109 0.11369947 0.01631677 0.08959710 0.04424249 Relative Value Short Selling Funds of Funds 0.00000000 0.00000000 0.00000000

This time, notice that as the weight increased in the convertible arb manager, so too did his contribution to maximum expected shortfall.

For a future backtest, I would like to make some data requests. I would like to use the universe found in Faber’s Global Asset Allocation book. That said, the simulations in that book go back to 1972, and I was wondering if anyone out there has daily returns for those assets/indices. While some ETFs go back into the early 2000s, there are some that start rather late such as DBC (commodities, early 2006), GLD (gold, early 2004), BWX (foreign bonds, late 2007), and FTY (NAREIT, early 2007). As an eight-year backtest would be a bit short, I was wondering if anyone had data with more history.

One other thing, I will in New York for the trading show, and speaking on the “programming wars” panel on October 6th.

Thanks for reading.

NOTE: While I am currently contracting, I am also looking for a permanent position which can benefit from my skills for when my current contract ends. If you have or are aware of such an opening, I will be happy to speak with you.

**leave a comment**for the author, please follow the link and comment on their blog:

**R – QuantStrat TradeR**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.