# Principal Component Analysis for attributing yield curve changes

I have calculated the Principal components using daily yield curve changes. After calculating these components, i noticed that 98% of the return can be attributed to the first 3 components.

How do i use these components to then say, if a bond with a specific maturity has returned +0.80%, i want to break that return by saying, e.g. 0.60% of the return comes from PC1, then 0.17% comes from PC2, etc. This is the step i am not getting. Below is an example of the desired output. Calculate the yield return, then show a pca decomposition of the return.

The PCA pertains to the attribution of changes (i.e. returns) of your valuation factors (e.g. zero rates across tenors) to latent "principal components", either thru eigendecomposition or thru SVD decomposition. Let $$X$$ denote the $$T\times k$$ matrix of observed zero rates shifts across the $$k$$ tenors of your curve, then

$$Cov(X)=\frac{1}{T}X'X=E\Lambda E^T \quad \mathrm{(eigen\ decomposition)}$$ with $$T \times k$$ prinicipal component matrix $$P=XE$$ (columnwise: time series per principal component) and the approximation
$$X^*=P^* (E^*)^T$$ (where we have only kept the first $$l\leq k$$ components in $$P^*,E^*$$) as the approximation to $$X$$. As $$X$$ (already) represents a matrix of returns, we can now 'explain' any observation date using the first couple of components. But before that, we need to connect the change in present value to the change in zero rates.To this end, let's model the present value of a simple coupon-bearing bond as:

$$PV = c\sum_i^n e^{-r(t_i)t_i}+e^{-r(t_n)t_n}$$ Note that the zero rate curve $$r(t_i)$$ is some interpolation function of the $$k$$ available interest rate tenors.

Disregarding the effect of the passage of calendar time (theta / decay), a first order approximation to the PnL of your instrument is

$$dPV\approx\sum_{j=1}^k\frac{\partial PV}{\partial r_j}dr_j=\Delta^Tdr$$ From above, the vector of rates changes, $$dr$$, is a row in $$X$$, and hence, given one observation of the prinicipal components $$p:(1\times k)$$:$$dr=Ep^T$$, or as an approximation, $$dr\approx E^*(p^*)^T$$. And finally

$$dPV\approx\Delta^Tdr\approx\Delta^TE^*(p^*)^T$$

where we have two sources of approximation: The linearization of the PnL and the cutoff of higher-order principal components.

Does that help?

## Update

I think you are not asking for the change in value of a bond, but of the values in $$X$$ above.

In a nutshell, we can re-use the above. Given a time series of yield changes $$X$$:

1. Estimate your eigen decomposition and store the $$k\times k$$ eigen vector matrix $$E$$, with components of $$E$$ ordered by magnutide of the corresponding eigen value in $$\Lambda$$ (I think any software library will do this automagically)
2. Calculate $$P$$, the collection of principal component time series, as above
3. Keep only the first relevant columns of $$P$$ (say four), and call this matrix $$P^*$$
4. Say your target is to explain the first entry in $$X$$, call it $$x_1$$. Then, $$x_1\approx (P^*)_{1}(E^*)^T$$, where $$E^*$$ contains only the first (say four) relevant eigen vectors, and $$(P^*)_{i}$$ is the $$i$$th row of $$P^*$$. I.e. you multiply the (first) principal components by the corresponding elements of the eigen vector; the result is the set of contributions to your PCA decomposition.