We usually compute **return attribution** to know how much each asset contributes to portfolio return. This calculation is quite easy because return formula is linear and sub-additive. In that context, one can split the whole portfolio return in smaller parts corresponding to each asset. However, although risk measures have to be coherent (monotonous, sub-additive, homogeneous and translational invariant), their formulas are a more complex representation than a linear function. Then, how can we compute **risk contribution**?

This post tries to solve the problem to obtain assets’ contribution in terms of a non-linear measure. In this occasion, the post will focus on risk, especially on volatility (a coherent measure), and explain a formula to get a sub-additive calculation for risk measures.

## Contribution as a concept

The idea of contribution is to have a formula like this:

\begin{array}{c}X_{P}=\sum_{i=1}^NCX_{i}=\sum_{i=1}^Nw_{i}x_{i}\qquad\qquad(1)\end{array}where X is any measure. This formula means that the contribution (CX) may be expressed as the weighted sum of each asset’s measure.

If this could be done with any measure, the post would end right now. Unfortunately, this is only possible with sub-additive measures, such as, return. Risk measures, on the contrary, are not usually sub-additive, and therefore an easy decomposition formula like that does not work.

But wait! Let’s see the solution.

## Return case

First of all, let’s see the case of portfolio return to understand the concept. This calculation is linear and sub-additive, so we can use directly (1) by changing the general X for the return R:

\begin{array}{c}R_{P}=\sum_{i=1}^NCR_{i}=\sum_{i=1}^Nw_{i}r_{i}=w_{1}r_{1}+…+w_{N}r_{N}\qquad\qquad(2)\end{array}Easy peasy! Here an understandable decomposition to get the return contribution.

## Risk case

However, in the case of risk, as most measures are not sub-additive, something else is needed, like the new formula that is proposed. Give it a go!

As it is known, there are many ways to compute risk in a portfolio: volatility, VaR, drawdown, etc. In most of them the interaction between assets takes part in the final value of the measure. For example, to get **portfolio volatility**, covariances (the relationship between assets) have an impact on the increase or decrease of the whole volatility. Then the risk is not sub-additive and this is the reason why this formula, which directly uses (1), is wrong:

### Marginal risk contribution

We want to present a calculation that meets the condition (1), put it in terms of volatility:

\begin{array}{c}\Sigma_{P}=\sum_{i=1}^NC\Sigma_{i}=\sum_{i=1}^Nw_{i}MC\Sigma_{i}\qquad\qquad(4)\end{array}To get that, we define the **marginal risk contribution (MCS)** as the decomposition of portfolio volatility into two components:

- the asset’s volatility, and
- the asset’s correlation with the portfolio return.

Additionally, taking into account the known formula of the correlation between an asset and the portfolio, we obtain the marginal risk contribution as the following one:

\begin{array}{c}MC\Sigma_{i}=\sigma_{i}\rho_{i,p}=\sigma_{i}\frac{\sigma_{i,p}}{\sigma_{P}}\qquad\qquad(5)\end{array}This formula gives a sub-additive expression for volatility. However, we should not mislead this result with the actual volatility of the assets. The figure that we get with the marginal risk contribution is only a number, that multiplied by the weight and added to the rest of measures of the assets in the portfolio, gets the portfolio’s volatility (following (4)).

Finally, from formula (4), we could get the **percentage of risk contribution** of each asset to the portfolio volatility:

## Practical case (with code)

Maybe, the formula expressed here is not so easy to understand, so let’s see an example to make things more clear.

Imagine a portfolio made of 9 assets that does not follow an equally weighted allocation. We want to compute the percentage of risk contribution of each asset to the portfolio risk by using the marginal risk contribution.

```
import numpy as np
weights = np.array([
0.13, 0.08, 0.07, 0.09, 0.19, 0.15, 0.06, 0.14, 0.09
])
covariances = np.array([
[0.00095687, 0.00052548, 0.00040974, 0.00059115, 0.00056328,
0.00103871, 0.00018933, 0.00104751, 0.00048049],
[0.00052548, 0.00044282, 0.00027017, 0.0003719, 0.0002999,
0.00074954, 0.00017665, 0.00066255, 0.00026227],
[0.00040974, 0.00027017, 0.00021823, 0.00025609, 0.00028768,
0.0005425, 0.00010583, 0.00051116, 0.00021496],
[0.00059115, 0.0003719, 0.00025609, 0.00059839, 0.00039637,
0.00059899, 0.0002022, 0.0006155, 0.00026622],
[0.00056328, 0.0002999, 0.00028768, 0.00039637, 0.00079571,
0.00068447, 0.00018267, 0.00079517, 0.0003302],
[0.00103871, 0.00074954, 0.0005425, 0.00059899, 0.00068447,
0.00173964, 0.00027611, 0.00148647, 0.00050011],
[0.00018933, 0.00017665, 0.00010583, 0.0002022, 0.00018267,
0.00027611, 0.00021069, 0.00029065, 0.00010041],
[0.00104751, 0.00066255, 0.00051116, 0.0006155, 0.00079517,
0.00148647, 0.00029065, 0.00151617, 0.00056435],
[0.00048049, 0.00026227, 0.00021496, 0.00026622, 0.0003302,
0.00050011, 0.00010041, 0.00056435, 0.00032909]
])
allocation_risk = np.sqrt(
np.dot(np.dot(weights, covariances), weights))
mcs = np.dot(weights, covariances) / allocation_risk
cs = weights * mcs
pcs= cs / allocation_risk
```

Next table shows that in this portfolio asset 6 contributes almost 23% of the portfolio’s risk, being one of the most risky assets. However, although asset 2 has a high volatility, its contribution is only 5.84% as its weight in the portfolio is low, only 8% of weight.

weight | volatility | MCS | CS | PCS | |
---|---|---|---|---|---|

asset 1 | 13% | 22.31% | 20.63% | 2.68% | 14.93% |

asset 2 | 8% | 15.17% | 13.10% | 1.05% | 5.84% |

asset 3 | 7% | 10.65% | 10.03% | 0.70% | 3.91% |

asset 4 | 9% | 17.64% | 13.49% | 1.21% | 6.76% |

asset 5 | 19% | 20.34% | 16.18% | 3.08% | 17.12% |

asset 6 | 15% | 30.08% | 27.44% | 4.12% | 22.92% |

asset 7 | 6% | 10.47% | 5.87% | 0.35% | 1.96% |

asset 8 | 14% | 28.08% | 27.07% | 3.79% | 21.11% |

asset 9 | 9% | 13.08% | 10.86% | 0.98% | 5.44% |

Sum (P) | 17.96% | 100% |

## Conclusion

To sum up, the formula (5) is an easy way to show the risk contribution of an individual asset to the whole portfolio, taking into account that volatility is not a sub-additive measure.

I encourage you to test it with other risk measures like VaR. I hope you find it useful!