Interest Rate Correlation, Part 4: Parameterising Correlation#
A model that prices a whole book needs the correlation between many rates at once, not one number for one pair. That is a matrix, and a matrix of correlations has to satisfy a constraint that a single number does not. This page sets out the usual ways of building it, the constraint, and what happens when it fails. It is the fourth of seven pages.
Structures#
Constant correlation. One number for every pair: \(\rho_{ij} = \rho\). It is simple and is often a starting point. It cannot say that nearby rates are more alike than distant ones.
Exponential decay. The correlation falls with the distance between the two rates, here the difference in expiry:
Rates that expire close together are highly correlated, and the correlation falls towards a long-run level \(\rho_\infty\) at a speed \(\beta\). With \(\beta = 0\) it is a one-factor model in which every correlation is 1, and with \(\rho_\infty = 0\) distant rates become independent. It has two parameters and a shape that agrees with how forward rates behave.
Expiry-dependent and tenor-dependent correlation. A function of the expiry of the option, the tenor of the swap, or both. It can fit a term structure of implied correlations (Interest Rate Correlation, Part 7: Calibration, Risk & Reserves) and has more parameters, which are less well identified.
Factor-based correlation. The \(n \times n\) matrix is written through a small number \(m\) of factors, \(\rho = B B^\top\) with \(B\) of size \(n \times m\), where each row of \(B\) has unit length. It is cheaper to simulate, since only \(m\) random numbers are drawn per step. Principal component analysis of a full matrix gives \(B\), and rank reduction keeps the leading components.
Positive semi-definiteness#
A correlation matrix must be positive semi-definite: all its eigenvalues must be zero or positive. Without it there are no random variables with those correlations, the Cholesky factorisation that generates correlated draws (Random Numbers & Sampling) fails, and a model that does not check it can quietly produce variances that are negative.
The structures above are positive semi-definite by construction: the exponential decay matrix is a mix of a constant matrix and a decaying one, both of which are, for \(0 \le \rho_\infty \le 1\). A matrix that is assembled pair by pair, from separately estimated or separately quoted correlations, is not. Each pair can be reasonable and the set can be impossible. If a rate is 90% correlated with a second and the second 90% with a third, the first and third cannot be negatively correlated.
The problem is worst when the correlations are high, since then the matrix is close to singular and a small inconsistency is enough to push an eigenvalue below zero.
Repair#
The standard repair finds the nearest correlation matrix to the faulty one, the closest positive semi-definite matrix with a unit diagonal. Higham’s algorithm does it by alternating between two projections, one onto the set of positive semi-definite matrices, by setting the negative eigenvalues to zero, and one onto the set of matrices with unit diagonal. It is a repair, and the matrix that results is not the one that was intended: every entry can change, and the change is largest where the original was most inconsistent.
Worked example#
The example builds three structures for ten forward rates that expire at 1 to 10 years, and compares their correlations and smallest eigenvalues. It finds the share of variance that each principal component explains, and the error from keeping one to four factors. It then repairs two matrices that are not positive semi-definite: three rates with pairwise correlations that are inconsistent, and a noisy matrix of ten rates.
Python code
"""Correlation structures for forward rates: constant, exponential decay and factor-based, with the positive semi-definite check and a repair."""
import numpy as np
YEARS = np.arange(1, 11) # ten annual forward rates, expiring at years 1 to 10
def exponential_decay(years, rho_inf, beta):
"""rho_ij = rho_inf + (1 - rho_inf) exp(-beta |T_i - T_j|)."""
gap = np.abs(years[:, None] - years[None, :])
return rho_inf + (1 - rho_inf) * np.exp(-beta * gap)
def constant(n, rho):
return np.full((n, n), rho) + (1 - rho) * np.eye(n)
def rank_reduce(corr, factors):
"""Keep the leading eigenvectors, then rescale each row so that the diagonal stays at one."""
w, v = np.linalg.eigh(corr)
order = np.argsort(w)[::-1][:factors]
loadings = v[:, order] * np.sqrt(w[order])
loadings = loadings / np.linalg.norm(loadings, axis=1, keepdims=True)
return loadings @ loadings.T, loadings
def nearest_correlation(a, iterations=200):
"""Higham's alternating projections: the closest correlation matrix in the Frobenius norm."""
y, delta = a.copy(), np.zeros_like(a)
for _ in range(iterations):
r = y - delta
w, v = np.linalg.eigh(r)
x = (v * np.maximum(w, 0.0)) @ v.T
delta = x - r
y = x.copy()
np.fill_diagonal(y, 1.0)
return y
def min_eigenvalue(m):
return np.linalg.eigvalsh(m).min()
def cholesky_works(m):
try:
np.linalg.cholesky(m)
return True
except np.linalg.LinAlgError:
return False
if __name__ == "__main__":
structures = {"Constant, 0.8": constant(10, 0.8), "Exponential decay, rho_inf 0.4, beta 0.15": exponential_decay(YEARS, 0.4, 0.15),
"Exponential decay, rho_inf 0.0, beta 0.15": exponential_decay(YEARS, 0.0, 0.15)}
print("Correlation between the forward rates expiring at 1 year and at 2, 5 and 10 years")
print(f"{'Structure':<44} {'1y-2y':>6} {'1y-5y':>6} {'1y-10y':>7} {'Smallest eigenvalue':>20}")
for name, m in structures.items():
print(f"{name:<44} {m[0, 1]:6.3f} {m[0, 4]:6.3f} {m[0, 9]:7.3f} {min_eigenvalue(m):20.4f}")
corr = structures["Exponential decay, rho_inf 0.4, beta 0.15"]
w = np.sort(np.linalg.eigvalsh(corr))[::-1]
print("\nPrincipal components of the exponential decay matrix: share of the variance")
shares = w / w.sum()
for k in range(4):
print(f" Factor {k + 1}: {shares[k]:.1%}, cumulative {shares[:k + 1].sum():.1%}")
print(f"\n{'Factors kept':>12} {'Largest error in the matrix':>28} {'1y-10y correlation':>20}")
for factors in (1, 2, 3, 4):
approx, _ = rank_reduce(corr, factors)
print(f"{factors:>12} {np.abs(approx - corr).max():28.4f} {approx[0, 9]:20.3f}")
# Three pairwise correlations that cannot all hold together.
bad = np.array([[1.0, 0.9, -0.5], [0.9, 1.0, 0.9], [-0.5, 0.9, 1.0]])
print(f"\nThree rates with pairwise correlations 0.9, 0.9 and -0.5: smallest eigenvalue {min_eigenvalue(bad):.3f}, Cholesky works: {cholesky_works(bad)}")
fixed = nearest_correlation(bad)
print(f"After the nearest-correlation repair: smallest eigenvalue {min_eigenvalue(fixed):.2e}, Cholesky works: {cholesky_works(fixed + 1e-10 * np.eye(3))}")
print(" entries changed from -> to: " + ", ".join(f"({i + 1},{j + 1}) {bad[i, j]:+.2f} -> {fixed[i, j]:+.3f}" for i in range(3) for j in range(i + 1, 3)))
# A matrix of pairwise estimates with noise: nearly singular matrices are the ones that fail.
rng = np.random.default_rng(3)
base = constant(10, 0.95)
noise = np.triu(rng.normal(0, 0.05, (10, 10)), 1)
noisy = base + noise + noise.T
print(f"\nTen rates, correlation 0.95 plus noise of 0.05 on each pair: smallest eigenvalue {min_eigenvalue(noisy):+.3f}, "
f"negative eigenvalues {int(np.sum(np.linalg.eigvalsh(noisy) < 0))}, Cholesky works: {cholesky_works(noisy)}")
repaired = nearest_correlation(noisy)
print(f"After repair: smallest eigenvalue {min_eigenvalue(repaired):+.2e}, largest change to an entry {np.abs(repaired - noisy).max():.3f}, "
f"average change {np.abs(repaired - noisy).mean():.4f}")
The output is:
Correlation between the forward rates expiring at 1 year and at 2, 5 and 10 years
Structure 1y-2y 1y-5y 1y-10y Smallest eigenvalue
Constant, 0.8 0.800 0.800 0.800 0.2000
Exponential decay, rho_inf 0.4, beta 0.15 0.916 0.729 0.556 0.0460
Exponential decay, rho_inf 0.0, beta 0.15 0.861 0.549 0.259 0.0767
Principal components of the exponential decay matrix: share of the variance
Factor 1: 78.9%, cumulative 78.9%
Factor 2: 10.6%, cumulative 89.5%
Factor 3: 4.1%, cumulative 93.6%
Factor 4: 2.0%, cumulative 95.7%
Factors kept Largest error in the matrix 1y-10y correlation
1 0.4445 1.000
2 0.1988 0.591
3 0.1150 0.624
4 0.0733 0.565
Three rates with pairwise correlations 0.9, 0.9 and -0.5: smallest eigenvalue -0.547, Cholesky works: False
After the nearest-correlation repair: smallest eigenvalue -1.07e-16, Cholesky works: True
entries changed from -> to: (1,2) +0.90 -> +0.608, (1,3) -0.50 -> -0.260, (2,3) +0.90 -> +0.608
Ten rates, correlation 0.95 plus noise of 0.05 on each pair: smallest eigenvalue -0.224, negative eigenvalues 3, Cholesky works: False
After repair: smallest eigenvalue -5.93e-16, largest change to an entry 0.127, average change 0.0272
Reading the output:
The decay structure gives a realistic shape. The correlation of the 1-year forward with the 2-year forward is 0.92, with the 5-year 0.73 and with the 10-year 0.56, against a constant 0.80 everywhere. Its smallest eigenvalue is 0.046, positive but small, which is why it needs watching.
The first factor carries 79% of the variance and four factors 96%. The first is a parallel move of the forwards, and the next ones are slope and curvature. A model with three factors captures 94%.
One factor is too few for a spread. Keeping a single factor makes every correlation 1, an error of 0.44 in the matrix, and the 1-year to 10-year correlation 1.000 instead of 0.556. Three factors give 0.624 and four give 0.565.
Inconsistent correlations break the factorisation. Pairwise correlations of 0.9, 0.9 and -0.5 give a smallest eigenvalue of -0.547 and a failed Cholesky. The repair gives 0.608, -0.260 and 0.608, so all three entries move, including the two that were each reasonable.
Noise breaks a near-singular matrix. A correlation of 0.95 with noise of 0.05 on each pair gives three negative eigenvalues. The repair changes entries by up to 0.127 and by 0.027 on average, which is as large as the effect of the noise that caused it.
A valuation control view#
Check positive semi-definiteness on every matrix that is used: the smallest eigenvalue, and whether the factorisation works. A tolerance is not enough: a matrix with an eigenvalue of -1e-3 can pass a loose test and fail another.
Record how a matrix is built and repaired: a repair changes the correlations that the model uses, and so the prices that depend on them. A matrix that is repaired every day is a finding, since the inputs are inconsistent.
Check the structure against the product: a one-factor or two-factor model cannot price a product that depends on a third factor. Compare the price with a richer model for the main spread products.
Look at small eigenvalues: a matrix with a very small eigenvalue is nearly singular, and the small factor it represents is hard to estimate. The prices that depend on it are the least reliable.
Compare the parameters across structures: a decay of \(\beta\) per year and a long-run level fitted to one set of instruments should be reasonable for the others, and should not change sharply from day to day. See Interest Rate Correlation, Part 7: Calibration, Risk & Reserves.
Next, Interest Rate Correlation, Part 5: From Forward-Rate to Swap-Rate Correlation looks at the link between the correlation of forward rates, which models use, and the correlation of swap rates, which the products depend on.