// file nels_sie.cc // author: Bernt A Oedegaard // purpose: Calculate the term structure proposed by Nelson and Siegel // Parsimonious Modeling of Yield Curves, Journal of Business, (1987) #include <math.h> double term_structure_yield_nelson_siegel(double t, double beta0, double beta1, double beta2, double lambda ) { if (t==0.0) return beta0; double tl = t/lambda; double r = beta0 + (beta1+beta2) * ((1-exp(-tl))/tl) + beta2 * exp(-tl); return r; };

This has 5 parameters to estimate: .

// file termstru_yield_bliss.cc // author: Bernt A Oedgaard #include <math.h> double term_structure_yield_bliss(double t, double gamma0, double gamma1, double gamma2, double lambda1, double lambda2) { double r; double t1 = t/lambda1; double t2 = t/lambda2; r = gamma0 + gamma1 * ( (1-exp(-t1)) / t1 ) + gamma2 * ( ( 1-exp(-t2)) / t2 ) + gamma2 * ( -exp(-t2)); return r; };

The cubic spline parameterization was first used by McCulloch (1971) to estimate the nominal term structure. He later added taxes in McCulloch (1975). The cubic spline was also used by Litzenberger and Rolfo (1984).

Here is the indicator function for an event , and we have

To estimate this we need to find the parameters:

If the spline knots are known, this is a simple linear regression.

// file: cu_spline.cc // author: Bernt A Oedegaard #include <math.h> #include <vector.h> double term_structure_discount_factor_cubic_spline(double t, double b1, double c1, double d1, const vector<double>& f, const vector<double>& knots) { // calculate the discount factor for the spline functional form. double d = 1.0 + b1*t + c1*(pow(t,2)) + d1*(pow(t,3)); for (int i=0;i<knots.size();i++) { if (t >= knots[i]) { d += f[i] * (pow((t-knots[i]),3)); } else { break; }; }; return d; };