GitHub profile

Formulae

Covariance Matrix

The covariance matrix is computed from the demeaned, log-differenced yields:

$$\mathbf{A} = \frac{1}{T-13}\widetilde{\mathbf{Y}}_c^\top \widetilde{\mathbf{Y}}_c$$

$\mathbf{A} \in \mathbb{R}^{N \times N}$ — one row and one column per maturity, so entry $a_{i,j}$ is the sample covariance between maturity $i$ and maturity $j$. The $T-13$ denominator is $(T-12)-1$: $\widetilde{\mathbf{Y}}_c$ has $T-12$ rows (months), and sample covariance divides by rows minus one.

Principal Component Scores

Projecting the demeaned, log-differenced yields onto the first 3 loadings gives the scores:

$$\mathbf{z}_3 = \widetilde{\mathbf{Y}}_c\mathbf{W}_3$$

$\mathbf{W}_3 \in \mathbb{R}^{N \times 3}$ is the loading matrix from Step 7, restricted to its first 3 columns (the top 3 components by eigenvalue).

$\mathbf{z}_3 \in \mathbb{R}^{(T-12)\times 3}$ — one row per observation (month), one column per retained component.

Reconstruction

Exact, using all $N$ components — a lossless rotation and rotation-back:

$$\widetilde{\mathbf{Y}}_c\mathbf{W}\mathbf{W}^\top = \widetilde{\mathbf{Y}}_c$$

Approximate, using only the first 3:

$$\widetilde{\mathbf{Y}}_c^{\text{approx}} = \mathbf{z}_3\,\mathbf{W}_3^\top$$

Since $\mathbf{W}_3$'s columns are orthonormal, the transpose serves in place of a true inverse. This is approximate rather than exact because $\mathbf{z}_3$ was never more than a 3-dimensional projection to begin with — whatever the discarded 68 components carried was already gone before reconstruction even starts, not lost in this step.