# Variance attribution calculation from a covariance matrix

Say I have a portfolio with two assets with weights $$(x, y)$$, and the covariance matrix of the two asset is $$((a, r)(r, b))$$. Then the total portfolio variance would be $$x^2a+2xyr+y^2b$$. It is easy to get that the percentage of the variance due to asset $$x$$ is $$\frac{x^2a+xyr}{x^2a+2xyr+y^2b}$$. I wonder in the n-dimensions cases, how to calculate the variance percentage for each asset mathematically based on the covariance matrix?

Suppose the covariance matrix is $$V$$ (which is n by n) and the weights are $$w$$ (of length n).

Then the Portfolio Variance is $$V_p = w^T V w$$

and the Risk Contribution (in terms of variance) of asset $$k$$ is

$$RC_k=w_k \sum_j V[k,j]w_j$$

in words this is "the weight of asset k times the inner product of the k-th row of $$V$$ and the weight vector". (Sometimes the "inner product of ..." just mentioned is given the name the Marginal Risk Contribution of asset $$k$$, which leads to the compact expression $$RC_k=w_k MRC_k$$).

We then have the "decomposition property" that $$V_p=\sum_k RC_k$$ or in percentage terms

$$\sum_k \frac{RC_k}{V_p}=1$$

If we apply this to the two by two case

$$V=\begin{bmatrix} a & r \\ r & b \\ \end{bmatrix}$$

and $$w=\begin{bmatrix}x \\ y \end{bmatrix}$$

we get that the total variance of the portfolio is $$V_p=a x^2+2 r x y + b y^2$$

The variance contribution of the first asset is $$RC_1=x(ax+ry)$$

and the percentage contribution is the ratio of these two (the latter divided by the former). This agrees with your result.

Two good references for these results are

Edward Qian: On the Financial Interpretation of Risk Contribution: Risk Budgets Do Add Up (2005)

S. Maillard, T. Roncalli: On the properties of equally-weighted risk contributions portfolios (2009)

also often cited is

D Tasche: Capital Allocation to Business Units and Sub-Portfolios: the Euler Principle (2008)

• This seems to assume that the factors account for all of the portfolio's variance. What about stock risk or specific risk as it is called in literature? May 11, 2020 at 18:01
• This is not the decomposition based on factors, it is the decomposition in terms of individual stock variances and covariances between individual stocks. (Feel free to ask another Question about factor decomposition, i.e. decomposition into factors and a residual). May 11, 2020 at 19:39