parameters, which corresponds to the one that maximises the sum of thelog-likelihood function or its negative as in equation (3.65). This estimation is performedin separate ﬁles, which run on the ﬁles used to estimate the Kalman ﬁlter.The starting values of the restricted parameters are inserted in the row after the comment“deﬁning parameters”. The single output of these ﬁles is an additional ﬁle containing theestimated parameters, which is created at the end of the Matlab ﬁle. The ﬁle correspondingto the Kalman ﬁlter ﬁle previously inserted is structured as follows:load c:\matlab\datgerin.txt;echo on;% creating the original parameters to be estimated% r11 to r1818 are the variances of the residuals in observation% equations% s10 and s20 are the starting values of the factors (subtracted by the% respective means)global delta phi1 phi2 sgm1 sgm2 lmda1 lmda2 r11 r22 r33 r44 r55 r66 r77r88 r99 r1010 r1111 r1212 r1313 r1414 r1515 r1616 r1717 r1818 r1919 s10s20;global AAr HH1r HH2r A H F R Q S10 Q0 p10 vp10 z;% defining data matrixdat=datgerin;global dat;% defining parameterspara=[4.0346916,4.0660162,-6.465255,-6.8215072,3.0979817,1.4923502,0.69015894,-0.17029679,-1.7801797,-1.2362226,-0.68102726,0.60983616,0.082530108,-0.14685034,-1.0676112,0.41457897,-0.31653961,-0.079408822,0.37790821,0.73490396,0.80506935,0.51061064,0.39230219,-0.56051416,2.7940033,-5.302371]global para;%options about the minimisation function used below (see Matlab manual)options(1)=1;options(2)=0.001;options(3)=0.001;options(14)=100000;% defining the optimisation problem (minimise -log-likelihood function)z=fmins(’va2fgrin’,para,options);% saving a file with the parameters;save c:\matlab\v2pgerin z -ascii;
Modelling the Term Structure of Interest Rates
101
The estimation procedure may be summarised as in Figure 3.5.The statistical signiﬁcance of the parameters was tested by computing the usual t-ratios,where the standard deviations were obtained from the variance–covariance matrix of theestimators (see e.g. Hamilton (1994, p. 389) for details), using a numerical procedure.The ﬁles used concerning the two-factor models mentioned above are also provided on
Starting values for the parametermatrices (A, H, C, F, R, Q)
Starting values for the state vector S
New value for S(3.58) and for P1|0 (3.59)
New value for Y (3.61)
Forecasting error of Y (3.62)
Variance matrix of the estimationerror of the observation equation (3.63)
Value of the log-likelihoodfunction (3.64)
Updating S (3.66) and P (3.67)
Forecasting the new values forS (3.68) and P (3.69)(if all iterationsare done)
(if there areiterations to be done)
Sum of the values of thelog-likelihood function (3.65)(if the maximum for thesum has been obtained)
(if the maximum hasn'tbeen obtained)
END
Figure 3.5
Kalman ﬁlter algorithm with unknown parameters
102
Applied Quantitative Methods for Trading and Investment
the CD-Rom – “v2trgrse”, “v2trgrsb” and “v2trgrin”, respectively – for the non-identiﬁedmodels using the shorter and longer databases and for the identiﬁed model.37The latter is inserted next. The routine starts by reading the data ﬁle, which includeda ﬁle with the original parameters estimated. The derivatives required are computed byarithmetic approximation, being the increment equal to 0.00001. Then the ﬁrst and thesecond derivatives are computed and a matrix S containing the second derivatives. Thet-ratios are the elements of the main diagonal of the matrix S2 = inv(S)/obs. Finally,three ﬁles are saved, containing respectively the t-ratios, the standard deviations and thematrix S2.% This is v2trgrin, a code for the estimation of t-ratios in atwo-factor identified Vasicek model for Germany estimated spot rates% By Jorge Barros Luis% loading dataload c:\matlab\datgerin.txt;% defining the variablesglobal delta phi1 phi2 sgm1 sgm2 lmda1 lmda2 r11 r22 r33 r44 r55 r66 r77r88 r99 s10 s20;global AAr HH1r HH2r A H F R Q S10 Q0 p10 vp10 z;% transposing the data column vectorY=datgerin’;% computing the number of observationsobs=length(Y(1,:));%loading the parameter vectorload v2pgerin.txt;para=v2pgerin;%definition of the variationsd=0.00001%variations for the second derivatives;incphi1=[d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];incphi2=[0,d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];incsgm1=[0,0,d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];incsgm2=[0,0,0,d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];inclmda1=[0,0,0,0,d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];inclmda2=[0,0,0,0,0,d,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];incdelta=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d];%parameters after the first variation;upphi1=para+incphi1;dwphi1=para-incphi1;upphi2=para+incphi2;dwphi2=para-incphi2;upsgm1=para+incsgm1;dwsgm1=para-incsgm1;upsgm2=para+incsgm2;dwsgm2=para-incsgm2;uplmda1=para+inclmda1;dwlmda1=para-inclmda1;uplmda2=para+inclmda2;dwlmda2=para-inclmda2;updelta=para+incdelta;37
Obviously, these ﬁles have to be run after the Kalman ﬁlter and maximum likelihood estimations.
Modelling the Term Structure of Interest Ratesdwdelta=para-incdelta;uph1uph2=para+incphi1+incphi2;uph1usg1=para+incphi1+incsgm1;uph1usg2=para+incphi1+incsgm2;uph1ulm1=para+incphi1+inclmda1;uph1ulm2=para+incphi1+inclmda2;uph1udel=para+incphi1+incdelta;uph2usg1=para+incphi2+incsgm1;uph2usg2=para+incphi2+incsgm2;uph2ulm1=para+incphi2+inclmda1;uph2ulm2=para+incphi2+inclmda2;uph2udel=para+incphi2+incdelta;usg1usg2=para+incsgm1+incsgm2;usg1ulm1=para+incsgm1+inclmda1;usg1ulm2=para+incsgm1+inclmda2;usg1udel=para+incsgm1+incdelta;usg2ulm1=para+incsgm2+inclmda1;usg2ulm2=para+incsgm2+inclmda2;usg2udel=para+incsgm2+incdelta;ulm1ulm2=para+inclmda1+inclmda2;ulm1udel=para+inclmda1+incdelta;ulm2udel=para+inclmda2+incdelta;uph1dph2=para+incphi1-incphi2;uph1dsg1=para+incphi1-incsgm1;uph1dsg2=para+incphi1-incsgm2;uph1dlm1=para+incphi1-inclmda1;uph1dlm2=para+incphi1-inclmda2;uph1ddel=para+incphi1-incdelta;uph2dsg1=para+incphi2-incsgm1;uph2dsg2=para+incphi2-incsgm2;uph2dlm1=para+incphi2-inclmda1;uph2dlm2=para+incphi2-inclmda2;uph2ddel=para+incphi2-incdelta;usg1dsg2=para+incsgm1-incsgm2;usg1dlm1=para+incsgm1-inclmda1;usg1dlm2=para+incsgm1-inclmda2;usg1ddel=para+incsgm1-incdelta;usg2dlm1=para+incsgm2-inclmda1;usg2dlm2=para+incsgm2-inclmda2;usg2ddel=para+incsgm2-incdelta;ulm1dlm2=para+inclmda1-inclmda2;ulm1ddel=para+inclmda1-incdelta;ulm2ddel=para+inclmda2-incdelta;dph1dph2=para-incphi1-incphi2;dph1dsg1=para-incphi1-incsgm1;dph1dsg2=para-incphi1-incsgm2;dph1dlm1=para-incphi1-inclmda1;dph1dlm2=para-incphi1-inclmda2;dph1ddel=para-incphi1-incdelta;dph2dsg1=para-incphi2-incsgm1;dph2dsg2=para-incphi2-incsgm2;dph2dlm1=para-incphi2-inclmda1;dph2dlm2=para-incphi2-inclmda2;dph2ddel=para-incphi2-incdelta;
103
104
Applied Quantitative Methods for Trading and Investment
dsg1dsg2=para-incsgm1-incsgm2;dsg1dlm1=para-incsgm1-inclmda1;dsg1dlm2=para-incsgm1-inclmda2;dsg1ddel=para-incsgm1-incdelta;dsg2dlm1=para-incsgm2-inclmda1;dsg2dlm2=para-incsgm2-inclmda2;dsg2ddel=para-incsgm2-incdelta;dlm1dlm2=para-inclmda1-inclmda2;dlm1ddel=para-inclmda1-incdelta;dlm2ddel=para-inclmda2-incdelta;dph1uph2=para-incphi1+incphi2;dph1usg1=para-incphi1+incsgm1;dph1usg2=para-incphi1+incsgm2;dph1ulm1=para-incphi1+inclmda1;dph1ulm2=para-incphi1+inclmda2;dph1udel=para-incphi1+incdelta;dph2usg1=para-incphi2+incsgm1;dph2usg2=para-incphi2+incsgm2;dph2ulm1=para-incphi2+inclmda1;dph2ulm2=para-incphi2+inclmda2;dph2udel=para-incphi2+incdelta;dsg1usg2=para-incsgm1+incsgm2;dsg1ulm1=para-incsgm1+inclmda1;dsg1ulm2=para-incsgm1+inclmda2;dsg1udel=para-incsgm1+incdelta;dsg2ulm1=para-incsgm2+inclmda1;dsg2ulm2=para-incsgm2+inclmda2;dsg2udel=para-incsgm2+incdelta;dlm1ulm2=para-inclmda1+inclmda2;dlm1udel=para-inclmda1+incdelta;dlm2udel=para-inclmda2+incdelta;%computation of the second partial derivatives (the elements of the maindiagonal of S);d2phi1=((v2ungrin(upphi1)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwphi1)))/d^2d2phi2=((v2ungrin(upphi2)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwphi2)))/d^2d2sgm1=((v2ungrin(upsgm1)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwsgm1)))/d^2d2sgm2=((v2ungrin(upsgm2)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwsgm1)))/d^2d2lmda1=((v2ungrin(uplmda1)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwlmda1)))/d^2d2lmda2=((v2ungrin(uplmda2)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwlmda2)))/d^2d2delta=((v2ungrin(updelta)-v2ungrin(para))-(v2ungrin(para)v2ungrin(dwdelta)))/d^2%computation of the cross derivatives (the elements out of the maindiagonal of S);dph1ph2=(v2ungrin(uph1uph2)-v2ungrin(uph1dph2)v2ungrin(dph1uph2)+v2ungrin(dph1dph2))/4*d^2dph1sg1=(v2ungrin(uph1usg1)-v2ungrin(uph1dsg1)v2ungrin(dph1usg1)+v2ungrin(dph1dsg1))/4*d^2
Modelling the Term Structure of Interest Rates
105
dph1sg2=(v2ungrin(uph1usg2)-v2ungrin(uph1dsg2)v2ungrin(dph1usg2)+v2ungrin(dph1dsg2))/4*d^2dph1lm1=(v2ungrin(uph1ulm1)-v2ungrin(uph1dlm1)v2ungrin(dph1ulm1)+v2ungrin(dph1dlm1))/4*d^2dph1lm2=(v2ungrin(uph1ulm2)-v2ungrin(uph1dlm2)v2ungrin(dph1ulm2)+v2ungrin(dph1dlm2))/4*d^2dph1delt=(v2ungrin(uph1udel)-v2ungrin(uph1ddel)v2ungrin(dph1udel)+v2ungrin(dph1ddel))/4*d^2dph2sg1=(v2ungrin(uph2usg1)-v2ungrin(uph2dsg1)v2ungrin(dph2usg1)+v2ungrin(dph2dsg1))/4*d^2dph2sg2=(v2ungrin(uph2usg2)-v2ungrin(uph2dsg2)v2ungrin(dph2usg2)+v2ungrin(dph2dsg2))/4*d^2dph2lm1=(v2ungrin(uph2ulm1)-v2ungrin(uph2dlm1)v2ungrin(dph2ulm1)+v2ungrin(dph2dlm1))/4*d^2dph2lm2=(v2ungrin(uph2ulm2)-v2ungrin(uph2dlm2)v2ungrin(dph2ulm2)+v2ungrin(dph2dlm2))/4*d^2dph2delt=(v2ungrin(uph2udel)-v2ungrin(uph2ddel)v2ungrin(dph2udel)+v2ungrin(dph2ddel))/4*d^2dsg1sg2=(v2ungrin(usg1usg2)-v2ungrin(usg1dsg2)v2ungrin(dsg1usg2)+v2ungrin(dsg1dsg2))/4*d^2dsg1lm1=(v2ungrin(usg1ulm1)-v2ungrin(usg1dlm1)v2ungrin(dsg1ulm1)+v2ungrin(dsg1dlm1))/4*d^2dsg1lm2=(v2ungrin(usg1ulm2)-v2ungrin(usg1dlm2)v2ungrin(dsg1ulm2)+v2ungrin(dsg1dlm2))/4*d^2;dsg1delt=(v2ungrin(usg1udel)-v2ungrin(usg1ddel)v2ungrin(dsg1udel)+v2ungrin(dsg1ddel))/4*d^2dsg2lm1=(v2ungrin(usg2ulm1)-v2ungrin(usg2dlm1)v2ungrin(dsg2ulm1)+v2ungrin(dsg2dlm1))/4*d^2dsg2lm2=(v2ungrin(usg2ulm2)-v2ungrin(usg2dlm2)v2ungrin(dsg2ulm2)+v2ungrin(dsg2dlm2))/4*d^2dsg2delt=(v2ungrin(usg2udel)-v2ungrin(usg2ddel)v2ungrin(dsg2udel)+v2ungrin(dsg2ddel))/4*d^2dlm1lm2=(v2ungrin(ulm1ulm2)-v2ungrin(ulm1dlm2)v2ungrin(dlm1ulm2)+v2ungrin(dlm1dlm2))/4*d^2dlm1delt=(v2ungrin(ulm1udel)-v2ungrin(ulm1ddel)v2ungrin(dlm1udel)+v2ungrin(dlm1ddel))/4*d^2dlm2delt=(v2ungrin(ulm2udel)-v2ungrin(ulm2ddel)v2ungrin(dlm2udel)+v2ungrin(dlm2ddel))/4*d^2%Matrix SS=1/obs*[d2phi1 dph1ph2 dph1sg1 dph1sg2 dph1lm1 dph1lm2 dph1delt;dph1ph2 d2phi2 dph2sg1 dph2sg2 dph2lm1 dph2lm2 dph2delt; dph1sg1 dph2sg1d2sgm1 dsg1sg2 dsg1lm1 dsg1lm2 dsg1delt; dph1sg2 dph2sg2 dsg1sg2 d2sgm2dsg2lm1 dsg2lm2 dsg2delt; dph1lm1 dph2lm1 dsg1lm1 dsg2lm1 d2lmda1dlm1lm2 dlm1delt; dph1lm2 dph2lm2 dsg1lm2 dsg2lm2 dlm1lm2 d2lmda2dlm2delt; dph1delt dph2delt dsg1delt dsg2delt dlm1delt dlm2deltd2delta];%T-ratiosS2=inv(S)/obs;tratios=[para(1)/sqrt(S2(1,1));para(2)/sqrt(S2(2,2));para(3)/sqrt(S2(3,3));para(4)/sqrt(S2(4,4));para(5)/sqrt(S2(5,5));para(6)/sqrt(S2(6,6));para(16)/sqrt(S2(7,7))];stdev=[sqrt(S2(1,1));sqrt(S2(2,2));sqrt(S2(3,3));sqrt(S2(4,4));sqrt(S2(5,5));sqrt(S2(6,6));sqrt(S2(7,7))];save c:\matlab\v2trgrin tratios -ascii;
106
Applied Quantitative Methods for Trading and Investment
save c:\matlab\v2sdgrin stdev -ascii;save c:\matlab\v2sgrin S2 -ascii;
3.7 ESTIMATION RESULTSBefore the estimation results, it is worthwhile to present the most signiﬁcant stylisedfacts concerning the data. The properties of the German yield curve are summarised inTables 3.1 and 3.2. A number of features are worth noting. Firstly, between 1986 and1998, the term structure is negatively sloped at the short end, in contrast with the morefamiliar concave appearance observed for the USA market (see Backus et al. (1997)).Secondly, yields are very persistent, with monthly autocorrelations above 0.98 for allmaturities.38 Thirdly, yields are highly correlated along the curve, but correlation is notequal to one, with lower correlations obtained for the ends of the yield curve. Thissuggests that non-parallel shifts of the yield curve are important. Therefore, one-factormodels seem to be insufﬁcient to explain the German term structure of interest rates.Lastly, as expected, the volatility curve of the yields is downward sloping.The ﬁrst estimations to be performed were those concerning the forward regressions.These regressions were run using a TSP routine with Newey–West standard errors.39Figure 3.6 (simple test) and Figure 3.7 (forward regressions) show the results of the testsTable 3.1
Properties of German government bond yields in 1986–1988
Maturity13122436486084Mean5.732 5.715 5.681 5.823 6.020 6.203 6.359 6.587St. Dev.2.267 2.224 2.087 1.882 1.686 1.524 1.398 1.228Skewness0.450 0.449 0.490 0.522 0.519 0.487 0.432 0.282Kurtosis−1.258 −1.267 −1.139 −1.051 −0.975 −0.871 −0.737 −0.426Autocorrelation 0.991 0.992 0.991 0.990 0.989 0.989 0.988 0.987
1206.7931.0950.0490.0010.983
Normality TestsMaturityχ 2 (2)P (X > x)
1312243648608412015.5558 15.6717 14.6832 14.2669 13.1898 11.1065 8.3923 3.2515 0.06270.0004 0.0004 0.0006 0.0008 0.0014 0.0039 0.0151 0.1968 0.9691
Correlation matrixy1y3y12y24y36y48y60y84y1203839
1.000
0.9981.000
0.9690.9821.000
0.9360.9550.9931.000
0.9130.9340.9800.9961.000
0.8910.9120.9640.9860.9971.000
Interest rates are close to being non-stationary.This routine is not included on the CD-Rom, as this is a trivial exercise.
0.8670.8890.9440.9720.9880.9971.000
0.8160.8390.8980.9350.9610.9800.9921.000
0.7430.7650.8290.8750.9110.9400.9620.9891.000
Modelling the Term Structure of Interest RatesTable 3.2
107
Properties of German government bond yields in 1972–1988
Maturity1224364860728496120Mean6.348 6.609 6.856 7.051 7.202 7.321 7.414 7.487 7.594St. Dev.2.290 2.053 1.891 1.770 1.674 1.598 1.535 1.483 1.401Skewness0.545 0.349 0.224 0.151 0.108 0.084 0.075 0.077 0.112Kurtosis−0.513 −0.671 −0.677 −0.636 −0.575 −0.495 −0.397 −0.281 −0.006Autocorrelation 0.981 0.985 0.985 0.985 0.985 0.985 0.985 0.984 0.981Normality TestsMaturityχ 2 (2)P (X > x)
122419.28 12.440.000 0.002
368.760.013
486.590.037
605.010.082
723.640.162
842.390.302
961.370.505
1200.670.715
0.9640.9931.000
0.9420.9790.9961.000
0.9190.9620.9860.9971.000
0.8960.9430.9730.9900.9981.000
0.8740.9240.9580.9800.9920.9981.000
0.8530.9060.9430.9680.9840.9940.9991.000
0.8120.8700.9120.9430.9640.9790.9890.9951.000
48607284Time to settlement (in months)
96
108
120
Correlation matrixy12y24y36y48y60y72y84y96y120
1.000
0.9861.000
8.07.5
%
7.06.56.05.55.00
12
24
36
Figure 3.6 Simple test of the pure expectations theory of interest rates. Forward rate averagecurve in 1986–1998
108
Applied Quantitative Methods for Trading and Investment1.10
1.05
1.05
1.00
1.00
0.95
0