Perform a PCA on the log returns of a blob of curves.

Description

Perform a PCA on the log returns of a blob of curves.

Details

This function performs a completely standard Principle Component Analysis on the returns of a set of curves.

The function treats each row of the blob as a curve. For the result to be sensible each row must be the same length and each column must relate the same maturities across rows. The time spacing between the observations in each row should also be approxiamtely constant, for example daily or monthly.

Based on whether absolute or relative returns are selected, the returns are calculated either as:

$$ M_{return}(i,j) = M_{rate}(i+1,j) - M_{rate}(i,j) $$

or

$$ M_{return}(i,j) = \ln \left( \frac{M_{rate}(i+1,j)}{M_{rate}(i,j)} \right) $$

Where the original blob is a matrix \( M_{rate} \) where element \( (i,j) \) is the rate with maturity \( (j) \) in row \( (i) \).

Example Sheet

PCA.xlsx

Arguments

  • curves Blob of curves, each row is a curve of the same length.
  • useRelative Indicates if the PCA is to be done on relative moves. If not then it will be done on absolute moves.(Boolean)

Validation

The Principal Component analysis is performed using the singular value decomposition in Accord.NET. Details on how to use Accord.NET and how the singular value decomposition can be used to perform a PCA can be found in the paper A Tutorial on Principal Component Analysis with the Accord.NET Framework.

We further compared the results of the PCA to those produced by Matlab. This can be seen in:

PCATest.m and PCATest.xlsx