Yield Curve - Fitting a Cubic Spline
Overview
The regression based cubic spline is one of the most common ways to fit the yield curve. It recognizes the fact that
there is noise in the prices of bonds, and that on any maturity date, you may have a range of prices to deal with.
The regression method uses
cubic spline
to fit the discount curve, here labeled {% d(t) %} and uses an
OLS Regression
to deal with the randomness in the problem.
The method outlined here follows the treatment in
Problem Setup
The price of a bond is equal to the sum of its discounted cash flows.
{% P = \sum_{i=1}^m CF(t_i) \times d(t_i) + \epsilon %}
Here, we recognize that given a discount curve, the price of a bond is not exactly equal to the discounted sum of its cash flows.
There is some noise in the bond prices, represented by the noise term {% \epsilon %}.
We assume that the discount curve is approximated by a cubic spline. That is, it is represented as
{% d(t) = 1 + \sum_{i=1}^s \alpha_i g_i(t) %}
Here the {% g_i(t) %} are a set of
basis functions.
Given this form of the discount curve, the price of a bond can be restated as
{% P = \sum_{i=1}^m CF_i(1 + \sum_{i=1}^s \alpha_i g_i(t_i)) + \epsilon %}
Fitting to Data
Next, we gather market data. In particular we gather a set of bonds with different maturities, and we note the price of each bond.
Each bond is indexed by {% i %} and each of its cash flows is assigned an index {% j %}.
Then the price of the {% i^{th} %} bond is given by
{% P_i = \sum_{j} CF_{ij}(1 + \sum_{k=1}^s \alpha_{k} g_{k}(t_{j})) %}
where {% t_{j} %} is the time of the {% j^{th} %} cash flow of the bond. (in this case bond i)
{% P_i - \sum_{j} CF_{i j} = \sum_{j=1} \sum_{k=1}^s CF_j \times \alpha_k \times g_k(t_{j}) + \epsilon %}
Exchanging the sum indices, we get
{% P_i - \sum_{j} CF_{i j} = \sum_{k=1}^s \alpha_{k} \sum_{j=1} CF_j \times g_k(t_{j}) + \epsilon %}
This can be rewritten in
matrix notation
as
{% \vec{P'} = C \vec{\alpha} %}
where
{% P'_i = P_i - \sum_{j=1} CF_j %}
that is the price of the ith bond minus the sum of its
cash flows.
The matrix {% C %} is then defined to be
{% C_{i k} = \sum_{j=1} CF_{ij} \times g_k(t_{j}) %}
where the sum is over the cash flows of the ith bond.
Implementation
Implementation