<< стр. 5(всего 19)СОДЕРЖАНИЕ >>
.
. пЈ°. .пЈ»
.
. . .
. .
Vart (yl,t+1 ) a2l П…2l,t
0 0 0

where al+j,t = (B1,j Пѓ1 + B2,j Пѓ2 )/n2 and 2l is the number of variables to estimate (r in
2 2 2 2

equation (3.48)). In this way we adjust simultaneously the yield curve and the volatility
curve, avoiding implausible estimates for the latter, generated by parameters that assure
adequate estimations for the yields.
Regarding equations (3.48) and (3.49), in this model A is a column vector with elements
aj,t for the п¬Ѓrst l rows (l = 9) and (B1,j Пѓ1 + B2,j Пѓ2 )/n2 for the next l rows; Xt is a
2 2 2 2

2l-dimension column vector of oneвЂ™s (r = 1), C is a column vector of zeros and F is a
k Г— k diagonal matrix, with typical element Fi,i = П•i .
In all these cases, the starting values for the parameters were computed as those min-
imising the squared sum of residuals between the estimated yields (with the factors being
zero) and the mean observed yields.28
When the link between the second factor and the inп¬‚ation is considered in line with
(3.41), the observation equation becomes:29

27
Therefore, the parameter l in the state-space model is equal to 9 and there are 18 equations in the measurement
equation of the model. Besides the recursive restrictions, the parameters were estimated subject to the usual
signal restrictions.
28
This minimisation was performed using the Excel Solver add-in.
29
In this case, only the two-factor model is п¬Ѓtted.
Modelling the Term Structure of Interest Rates 89
пЈ® пЈ№пЈ® пЈ№пЈ® пЈ№ пЈ® пЈ№
y1,t a1,t b1,1 b2,1 П…1,t
пЈЇ пЈє пЈЇ a2,t пЈє пЈЇ b1,2 b2,2 пЈє пЈЇ П…2,t пЈє
y2,t
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈє пЈЇ пЈє
пЈЇ пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
пЈЇ пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
. пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
пЈЇ
пЈЇ пЈє пЈЇ al,t пЈє пЈЇ b1,l b2,l пЈє пЈЇ П…l,t пЈє
yl,t
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈєs пЈЇ пЈє
пЈЇ Vart (y1,t+1 ) пЈє = пЈЇ al+1,t пЈє + пЈЇ 0 0 пЈє 1,t + пЈЇ П…l+1,t пЈє (3.55)
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈєs пЈЇ пЈє
пЈЇ Vart (y2,t+1 ) пЈє пЈЇ al+2,t пЈє пЈЇ 0 0 пЈє 2,t пЈЇ П…l+2,t пЈє
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈє пЈЇ пЈє
пЈЇ пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
пЈЇ пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
. пЈє пЈЇ . пЈє пЈЇ. .пЈє пЈЇ.пЈє
пЈЇ
пЈ° Vart (yl,t+1 ) пЈ» пЈ° a2l пЈ» пЈ° 0 0пЈ» пЈ° П…2l,t пЈ»
Лњ
ПЂt bПЂ П…ПЂ
0 0

This model is estimated with the п¬Ѓles вЂњva2fgrinвЂќ and вЂњv2mlgrinвЂќ on the CD-Rom,
containing respectively the Kalman п¬Ѓlter and the maximum likelihood procedure, also
written in Matlab code. Conversely, when the inп¬‚ation is modelled as motivated by two
factors, as in (3.42), the observation equation is:
пЈ® пЈ№пЈ® пЈ№ пЈ® пЈ№ пЈ® пЈ№
a1,t
y1,t b1,1 П…1,t
b2,1 0
пЈЇ пЈєпЈЇ пЈє пЈЇ b1,2 0пЈє пЈЇ П…2,t пЈє
a2,t
y2,t b2,2
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈє пЈЇ пЈє
пЈЇ пЈєпЈЇ пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
. .
пЈЇ пЈєпЈЇ пЈє пЈЇ. .пЈє пЈЇ .пЈє
.
. .
.
. пЈє пЈЇ. . . пЈєпЈ® пЈ№пЈЇ.пЈє
пЈЇ пЈєпЈЇ
пЈЇ пЈєпЈЇ пЈє пЈЇ b1,l пЈЇ П…l,t пЈє
0 пЈє s1,t
al,t
yl,t b2,l
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈЇ
пЈє пЈє
пЈЇ Vart (y1,t+1 ) пЈє = пЈЇ пЈє+пЈЇ 0 0 пЈє пЈ° s2,t пЈ» + пЈЇ П…l+1,t пЈє
al+1,t (3.56)
0
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈє пЈЇ пЈє
пЈЇ Vart (y2,t+1 ) пЈє пЈЇ пЈє пЈЇ0 0 пЈє s1ПЂ,t пЈЇ П…l+2,t пЈє
al+2,t 0
пЈЇ пЈєпЈЇ пЈєпЈЇ пЈє пЈЇ пЈє
пЈЇ пЈєпЈЇ пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
. .
пЈЇ пЈєпЈЇ пЈє пЈЇ. .пЈє пЈЇ.пЈє
.
. .
.
. пЈє пЈЇ. . .пЈє пЈЇ.пЈє
пЈЇ пЈєпЈЇ
пЈ° Vart (yl,t+1 ) пЈ» пЈ° пЈ» пЈ°0 пЈ» пЈ° П…2l,t пЈ»
a2l 0 0
Лњ
ПЂt b2ПЂ b1ПЂ П…ПЂ
0
0

In this case, the transition equation becomes:
пЈ® пЈ№пЈ® пЈ№пЈ® пЈ№пЈ® пЈ№пЈ® пЈ№
s1,t+1 П•1 0 s1,t Пѓ1 Оµ1,t+1
0 0 0
пЈ° s2,t+1 пЈ» = пЈ° 0 П•2 пЈ» пЈ° s2,t пЈ» + пЈ° 0 0 пЈ» пЈ° Оµ2,t+1 пЈ»
Пѓ2 (3.57)
0
s1ПЂ,t+1 0 0 П•1ПЂ s1ПЂ,t Пѓ1ПЂ Оµ1ПЂ,t+1
0 0

The routines for this model are not included, given that they are very similar to the
previous ones. For instance, the model in equations (3.56) and (3.57) is similar to the one
Лњ
in equations (3.53) and (3.54), adding to this an observation equation for the variable ПЂt
or its determining factor.
All the Matlab routines used have a similar structure: after the introductory comments,
a set of general procedures is deп¬Ѓned. These start with the deп¬Ѓnition of the log-likelihood
function, followed by the loading of the sample data. Afterwards, the original parameters
and the matrices are deп¬Ѓned, as well as some self-explanatory procedures. The following
block of the routine is focused on the deп¬Ѓnition of the transformed parameters. These
are created in the next block of the routine (вЂњDeп¬Ѓning the Original ParametersвЂќ), in
order to allow us to deп¬Ѓne the original parameters as functions of the former, imposing
constraints on the original parameter values such as the mean-reversion coefп¬Ѓcients of
the factors (П•i ) to be between zero and one, the volatilities of the factors (Пѓi ) and the
variances of the errors in the observation errors to be positive and one of the market
90 Applied Quantitative Methods for Trading and Investment

prices of risk to be negative,30 so as to impose the risk-premium curve to be mostly
positive. In this block, the starting values of the factors for the Kalman п¬Ѓlter are also
settled to zero.
The matrices containing several factor loadings for the different maturities in equations
(3.24) and (3.25) are deп¬Ѓned next, as well as the recursive restrictions on those factor
loadings. In the routine block entitled вЂњDeп¬Ѓning the matrices for the estimationвЂќ, all the
matrices to write the Kalman п¬Ѓlter in the state-space form are settled. We start by com-
puting the factor loadings for the maturities considered in the sample.31 Then the column
vector A is formed, with rows 10 to 18 containing the volatilities as in equation (3.29).32
The 19th row is zero, as the inп¬‚ation only depends on the second factor and does not
have an independent term. The matrix H , containing the factor loadings in the observa-
tion equations, is formed next. Given that the volatilities are constant, rows 10 to 18 are
null. The 19th row contains the link between the inп¬‚ation and the second factor, as in
equation (3.41).
Subsequently, the matrix F containing the mean-reversion parameters of the factors
is formed. As the factors are assumed to be independent, only the elements in the main
diagonal are non-zero. After creating the matrices with the variances of the errors of
the observation and the state equations, the volatility and the term premium curves are
computed for the maturities considered in the sample.
The estimation of the Kalman п¬Ѓlter is performed afterwards. It departs from assuming
that the starting value of the state vector S is obtained from a normal distribution with
Л†
Л†
mean S0 and variance P0 . S0 can be seen as a guess concerning the value of S using all
information available up to and including t = 0. As the residuals are orthogonal to the
Л†
state variables, S0 cannot be obtained using the data and the model. P0 is the uncertainty
about the prior on the values of the state variables.
The next step is to obtain a п¬Ѓrst estimate for the mean and the variance of the state
Л†
variables. Concerning the former, from S0 and equation (3.49), the optimal estimator for
S1 will be:
Л† Л†
S1|0 = C + F S0 (3.58)

Conversely, the varianceвЂ“covariance matrix will be updated as follows:
Л† Л†
P1|0 = E[(S1 в€’ S1|0 )(S1 в€’ S1|0 ) ]
= E[(C + F S0 + Gv1 в€’ C в€’ F S0 )(C + F S0 + Gv1 в€’ C в€’ F S0 ) ]
= E[(F v0 + Gv1 )(v0 F + v1 G )]
= E(F v0 v0 F ) + E(Gv1 v1 G )
= FP1|0 F + GQ1 G (3.59)

Given that vec(ABC) = (C вЉ— A) В· vec(B), P1|0 may be obtained from:33

30
In this case, we opted for the second factor.
31
The element in brackets is the column number in the matrices A and H of the observation equations, which
corresponds to the maturity in months added by one, given that the п¬Ѓrst column of each of those matrices is
the initial factor loadings (a0 and bk,0 ).
32
The expression in equation (3.29) is multiplied by 1200 in order to annualise the yields and express them as
percentages.
33
In the Matlab routines, we start by updating the varianceвЂ“covariance matrix in the vector form.
Modelling the Term Structure of Interest Rates 91

vec(P1|0 ) = vec(FP1|0 F ) + vec(GQ1 G )
= (F вЉ— F ) В· vec(P1|0 ) + (G вЉ— G) В· vec(Q1 )
в€’1
= в€’(F вЉ— F ) [(G вЉ— G) В· vec(Q1 )] (3.60)
I
(r 2 Г—r 2 )

This block of the routine is concluded by assuming that the starting value of the log-
likelihood function is zero. The following block, entitled вЂњDerivation of the KFвЂќ, starts by
the estimation of the independent variables, based on the assumption that wt is independent
from Xt and from all prior information on y and x (denoted by О¶tв€’1 ). Therefore, the
forecast of yt conditional on Xt and О¶tв€’1 can be obtained directly from (3.48):

Л†
E(yt |Xt , О¶tв€’1 ) = AXt + H St|tв€’1 (3.61)

The several estimates from equation (3.61) are stored in a matrix deп¬Ѓned as YE in the
routines, where the number of rows corresponds to the number of observation equations
and the number of columns is the number of observations added by one. Given that wt is
Л†
also independent from St and St|tв€’1 , from equations (3.48) and (3.61), the forecast error
corresponds to:

Л† Л†
yt в€’ E(yt |Xt , О¶tв€’1 ) = (AXt + H St + wt ) в€’ (AXt + H St|tв€’1 ) = H (St в€’ St|tв€’1 ) + wt
(3.62)
From (3.62) the conditional varianceвЂ“covariance matrix of the estimation error of the
observation vector will be:34

E{[yt в€’ E(yt |Xt , О¶tв€’1 )][yt в€’ E(yt |Xt , О¶tв€’1 )] }
Л† Л†
= E{[H (St в€’ St|tв€’1 ) + wt ][H (St в€’ St|tв€’1 ) + wt ] }
Л† Л†
= HE [(St в€’ St|tв€’1 )(St в€’ St|tв€’1 ) ]H + E(wt wt )
= HP t|tв€’1 H + R (3.63)

After the updates of the mean and varianceвЂ“covariance matrices of the dependent
variables, the log-likelihood function is computed. In our Kalman п¬Ѓlter exercise, the
likelihood function is deп¬Ѓned as follows:35

f (yt |Itв€’1 ) = (2ПЂ )в€’1/2 |HP t|tв€’1 H + R|в€’1/2
Л† Л†
Г— exp в€’ 1 (yt в€’ A в€’ H St|tв€’1 ) (HP t|tв€’1 H + R)в€’1 (yt в€’ A в€’ H St|tв€’1 )
2

(3.64)

34
Notice that from equations (3.48) and (3.61), the forecast error corresponds to:
Л† Л†
yt в€’ E(yt |Xt , О¶tв€’1 ) = (AXt + H St + wt ) в€’ (AXt + H St|tв€’1 ) = H (St в€’ St|tв€’1 ) + wt
35
As the latter depends on the residuals of the observation equations, these are previously deп¬Ѓned in the Matlab
routines.
92 Applied Quantitative Methods for Trading and Investment

As usual, the optimisation procedure will be performed as a minimisation problem.
Thus, the negative of the log-likelihood function is computed:

T
в€’ log L(YT ) = в€’ log f (yt |Itв€’1 ) (3.65)
t=1

Л†
It can be shown that the distribution of St given yt , Xt and О¶tв€’1 is N (St|t , Pt|t ), where
Л†
St|t and Pt|t are respectively the optimal forecast of St given Pt|t and the mean square error
of this forecast, corresponding to the following updating equations of the Kalman п¬Ѓlter.
After the initial estimate of the dependent variables, the mean and the varianceвЂ“covariance
matrices of the Kalman п¬Ѓlter may be updated as follows:

Л† Л†
St|t = St|tв€’1 + Pt|tв€’1 H (HP t|tв€’1 H + R)в€’1 [yt в€’ (AXt + Ht|tв€’1 )] (3.66)
Pt|t = Pt|tв€’1 в€’ Pt|tв€’1 H (HP t|tв€’1 H + R)в€’1 HP t|tв€’1 (3.67)

Following this update, a new estimate for these matrices can be obtained, generalising
(3.58) and (3.59):36

Л† Л†
St+1|t = C + F St|t
Л†
= C + F {St|tв€’1 + Pt|tв€’1 H (HP t|tв€’1 H + R)в€’1 [yt в€’ (AXt + Ht|tв€’1 )]}
= C + F S t|tв€’1 + FP t|tв€’1 H (HP t|tв€’1 H + R)в€’1 [yt в€’ (AXt + Ht|tв€’1 )]
Л† (3.68)

Pt+1|t = FP t|t F + GQ t G
= F [Pt|tв€’1 в€’ Pt|tв€’1 H (HP t|tв€’1 H + R)в€’1 HP t|tв€’1 ]F + GQ t G
= FP t|tв€’1 F в€’ FP t|tв€’1 H (HP t|tв€’1 H + R)в€’1 HP t|tв€’1 F + GQ t G (3.69)

At the end of each update of the Kalman п¬Ѓlter, the volatility and the term premium
curves are computed. Considering that only Gaussian models were п¬Ѓtted, these curves
move only when different values for the parameters are considered, as they do not depend
on the factor values. Finally, concluding the routines, there are two blocks where the
results are stored in matrices and п¬Ѓles and charts for the yields, volatility curves, factors
and inп¬‚ation (in the identiп¬Ѓed models) are produced. The Matlab routine written to run
the Kalman п¬Ѓlter for the two-factor identiп¬Ѓed model is presented next.

% This is va2fgrin, a 2-factor Vasicek model, with an identified
% factor, for Germany spot curve estimated using the Kalman Filter
% By Jorge Barros Luis
% Estimation on 1m, 1y, 2y, 3y, 4y, 5y, 7y, 10y
% ==============================GENERAL PROCEDURES======================
% computing the log-likelihood function defined below
function lf=va2fgrin(para);

The matrix FP t|tв€’1 H (HP t|tв€’1 H + R)в€’1 is usually known as the gain matrix, since it determines the update
36

Л†
in St+1|t due to the estimation error of yt . Equation (3.68) is known as a Ricatti equation.
Modelling the Term Structure of Interest Rates 93
% creating the original parameters to be estimated
% r11 to r1919 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 r77
r88 r99 r1010 r1111 r1212 r1313 r1414 r1515 r1616 r1717 r1818 r1919 s10
s20;
global AAr HH1r HH2r A H F R Q S10 Q0 p10 vp10 z;
% transposing the data column vector
Y=datgerinвЂ™;
% computing the number of observations
obs=length(Y(1,:));
% creating a row vector of 1вЂ™s with No. of columns equal to the number
% of observations
X=ones(1,obs);
% computing the longest term for the restrictions on the parameters (in
% months)
NN=10*12+1;
%=========DEFINING THE TRANSFORMED OR UNRESTRICTED PARAMETERS==========
% these parameters are defined as to impose restrictions on the
% original parameters (e.g. sigmaвЂ™s have to be positive, phiвЂ™s have to
% be between 0 and 1,
% one of the lambdaвЂ™s has to be negative in order to have positive term
% premia and the variances of the residuals have to be positive)
% persistence parameters (phi1 and phi2)
a1=para(1); a2=para(2);
% volatilities (sigma 1 and sigma2)
b1=para(3); b2=para(4);
% lambdaвЂ™s (the market price of risks), defined as the product between
% the lambdaвЂ™s and the sigmaвЂ™s in the chapter
c1=para(5); c2=para(6);
% variances of the residuals in observation equation errors
d1=para(7); d2=para(8); d3=para(9); d4=para(10); d5=para(11);
d6=para(12); d7=para(13); d8=para(14); d9=para(15);
d10=para(16); d11=para(17); d12=para(18); d13=para(19); d14=para(20);
d15=para(21); d16=para(22); d17=para(23); d18=para(24); d19=para(25);
% conditional mean of short-term interest rate;
e1=para(26);
%==================DEFINING THE ORIGINAL PARAMETERS==================
% conditional mean of short-term interest rate;
delta=exp(e1);
% constrain persistence parameters (phiвЂ™s) to be positive and <1;
phi1=0.999/(1+exp(-a1));
phi2=0.999/(1+exp(-a2));
% constrain volatilities (sigmaвЂ™s) to be positive;
sgm1=exp(b1);
sgm2=exp(b2);
% constrain the 2st market price of risk (lamda2) to be negative;
lmda1=c1;
lmda2=-exp(c2);
% constrain variances of the observation equation errors
94 Applied Quantitative Methods for Trading and Investment
r11=exp(d1);
r22=exp(d2);
r33=exp(d3);
r44=exp(d4);
r55=exp(d5);
r66=exp(d6);
r77=exp(d7);
r88=exp(d8);
r99=exp(d9);
r1010=exp(d10);
r1111=exp(d11);
r1212=exp(d12);
r1313=exp(d13);
r1414=exp(d14);
r1515=exp(d15);
r1616=exp(d16);
r1717=exp(d17);
r1818=exp(d18);
r1919=exp(d19);
% initial values for the state variables;
s10=0;
s20=0;
%======================================================================
% creating a row vector of the original parameters
P=zeros(1,6);
P(1,1)=phi1;
P(1,2)=phi2;
P(1,3)=sgm1;
P(1,4)=sgm2;
P(1,5)=lmda1;
P(1,6)=lmda2;
%===========DEFINING ZERO ROW VECTORS WITH DIMENSION=NN================
%Matrices of observation equations in (3.48)
AAr=zeros(1,NN);
HH1r=zeros(1,NN);
HH2r=zeros(1,NN);
for n=2:NN
% Equation (3.24)
AAr(n)=delta+AAr(n-1)+0.5*(lmda1^2+lmda2^2-(lmda1+HH1r(n-1)*sgm1)^2-
(lmda2+HH2r(n-1)*sgm2)^2);
% Equation (3.25)
HH1r(n)=1+phi1*HH1r(n-1);
HH2r(n)=1+phi2*HH2r(n-1);
end
%==============Defining the matrices for estimation====================
% Estimated factor loadings for the maturities considered in the sample
% 1m
A1=AAr(2);
H11=HH1r(2);
H12=HH2r(2);
% 3m
A2=AAr(4);
H21=HH1r(4);
Modelling the Term Structure of Interest Rates 95
H22=HH2r(4);
% 1y
A3=AAr(13);
H31=HH1r(13);
H32=HH2r(13);
% 2y
A4=AAr(25);
H41=HH1r(25);
H42=HH2r(25);
% 3y
A5=AAr(37);
H51=HH1r(37);
H52=HH2r(37);
% 4y
A6=AAr(49);
H61=HH1r(49);
H62=HH2r(49);
% 5y
A7=AAr(61);
H71=HH1r(61);
H72=HH2r(61);
% 7y
A8=AAr(85);
H81=HH1r(85);
H82=HH2r(85);
% 10y
A9=AAr(121);
H91=HH1r(121);
H92=HH2r(121);
% creating a column vector (18 rows) of AвЂ™s (independent term of the
% observation equation in (3.48))
A=zeros(19,1);
A(1,1)=A1/1;
A(2,1)=A2/3;
A(3,1)=A3/12;
A(4,1)=A4/24;
A(5,1)=A5/36;
A(6,1)=A6/48;
A(7,1)=A7/60;
A(8,1)=A8/84;
A(9,1)=A9/120;
A(10,1)=1200/(1^2)*(H11^2*sgm1^2+H12^2*sgm2^2);
A(11,1)=1200/(3^2)*(H21^2*sgm1^2+H22^2*sgm2^2);
A(12,1)=1200/(12^2)*(H31^2*sgm1^2+H32^2*sgm2^2);
A(13,1)=1200/(24^2)*(H41^2*sgm1^2+H42^2*sgm2^2);
A(14,1)=1200/(36^2)*(H51^2*sgm1^2+H52^2*sgm2^2);
A(15,1)=1200/(48^2)*(H61^2*sgm1^2+H62^2*sgm2^2);
A(16,1)=1200/(60^2)*(H71^2*sgm1^2+H72^2*sgm2^2);
A(17,1)=1200/(84^2)*(H81^2*sgm1^2+H82^2*sgm2^2);
A(18,1)=1200/(120^2)*(H91^2*sgm1^2+H92^2*sgm2^2);
A(19,1)=0;
% creating a 18*2 matrix of HвЂ™s (coefficient matrix of observation
% equation in (3.48))
H=zeros(19,2);
96 Applied Quantitative Methods for Trading and Investment
H(1,1)=H11/1;
H(1,2)=H12/1;
H(2,1)=H21/3;
H(2,2)=H22/3;
H(3,1)=H31/12;
H(3,2)=H32/12;
H(4,1)=H41/24;
H(4,2)=H42/24;
H(5,1)=H51/36;
H(5,2)=H52/36;
H(6,1)=H61/48;
H(6,2)=H62/48;
H(7,1)=H71/60;
H(7,2)=H72/60;
H(8,1)=H81/84;
H(8,2)=H82/84;
H(9,1)=H91/120;
H(9,2)=H92/120;
H(10,1)=0;
H(10,2)=0;
H(11,1)=0;
H(11,2)=0;
H(12,1)=0;
H(12,2)=0;
H(13,1)=0;
H(13,2)=0;
H(14,1)=0;
H(14,2)=0;
H(15,1)=0;
H(15,2)=0;
H(16,1)=0;
H(16,2)=0;
H(17,1)=0;
H(17,2)=0;
H(18,1)=0;
H(18,2)=0;
H(19,1)=0;
H(19,2)=1/phi2;
% creating a 2*2 matrix of FвЂ™s (coefficient matrix of state equations
% in (3.49))
F=zeros(2,2);
F(1,1)=phi1;
F(2,2)=phi2;
% creating the variance-covariance matrix of the observation equation
% errors in (3.48)
R=zeros(19,19);
R(1,1)=r11;
R(2,2)=r22;
R(3,3)=r33;
R(4,4)=r44;
R(5,5)=r55;
R(6,6)=r66;
R(7,7)=r77;
R(8,8)=r88;
Modelling the Term Structure of Interest Rates 97
R(9,9)=r99;
R(10,10)=r1010;
R(11,11)=r1111;
R(12,12)=r1212;
R(13,13)=r1313;
R(14,14)=r1414;
R(15,15)=r1515;
R(16,16)=r1616;
R(17,17)=r1717;
R(18,18)=r1818;
R(19,19)=r1919;
% creating the variance-covariance matrix of the state equation errors
in (3.49)
Q=zeros(2,2);
Q(1,1)=sgm1^2;
Q(2,2)=sgm2^2;
% creating the matrix of the volatility curve in Equation (3.29), in %
V=zeros(9,obs+1);
V(1,1)=1/(1^2)*(H11^2*sgm1^2+H12^2*sgm2^2)*1200^2;
V(2,1)=1/(3^2)*(H21^2*sgm1^2+H22^2*sgm2^2)*1200^2;
V(3,1)=1/(12^2)*(H31^2*sgm1^2+H32^2*sgm2^2)*1200^2;
V(4,1)=1/(24^2)*(H41^2*sgm1^2+H42^2*sgm2^2)*1200^2;
V(5,1)=1/(36^2)*(H51^2*sgm1^2+H52^2*sgm2^2)*1200^2;
V(6,1)=1/(48^2)*(H61^2*sgm1^2+H62^2*sgm2^2)*1200^2;
V(7,1)=1/(60^2)*(H71^2*sgm1^2+H72^2*sgm2^2)*1200^2;
V(8,1)=1/(84^2)*(H81^2*sgm1^2+H82^2*sgm2^2)*1200^2;
V(9,1)=1/(120^2)*(H91^2*sgm1^2+H92^2*sgm2^2)*1200^2;
% creating the matrix of the term premium in Equation (3.30), in %
T=zeros(9,obs+1);
T(1,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H11*sgm1)^2+(lmda2+H12*sgm2)^2))*1200;
T(2,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H21*sgm1)^2+(lmda2+H22*sgm2)^2))*1200;
T(3,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H31*sgm1)^2+(lmda2+H32*sgm2)^2))*1200;
T(4,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H41*sgm1)^2+(lmda2+H42*sgm2)^2))*1200;
T(5,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H51*sgm1)^2+(lmda2+H52*sgm2)^2))*1200;
T(6,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H61*sgm1)^2+(lmda2+H62*sgm2)^2))*1200;
T(7,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H71*sgm1)^2+(lmda2+H72*sgm2)^2))*1200;
T(8,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H81*sgm1)^2+(lmda2+H82*sgm2)^2))*1200;
T(9,1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H91*sgm1)^2+(lmda2+H92*sgm2)^2))*1200;
%===================== Starting the Kalman Filter ====================
% creating the matrix of the unobservable factors (2*obs+1, as the
% starting values are included)
S10=zeros(2,obs+1);
% assuming starting values for the factors
S10(1,1)=s10;
S10(2,1)=s20;
98 Applied Quantitative Methods for Trading and Investment
% length of the vector of the initial values for the factors;
rr=length(S10(:,1));
% Unconditional variance of the state vector (in vector form)
% Equation (3.60)
vp10=inv(eye(rr^2)-kron(F,F))*reshape(Q,rr*rr,1);
% Unconditional variance of the state vector (in matrix form)
% Equation (3.59)
p10=reshape(vp10,rr,rr)вЂ™;
% Initial value for the likelihood function
lf=0;
%====================== Derivation of the KF ==========================
for t=1:obs
% Forecasting Yt|t-1 (equation (3.61))
y10=(A*X(:,t)+H*S10(:,t))*1200;
% Creating matrix of estimated Y
YE(:,t:t)=y10;
% covariance of Yt-Yt|t-1 (equation (3.63))
O10=H*p10*HвЂ™+R;
kk=length(R(:,1));
%================== Calculate the likelihood function =================
% Forecast error (equation (3.62))
res=Y(:,t)-y10;
% log likelihood function (equation (3.64))
ff=-0.5*log(2*pi*det(O10))-0.5*resвЂ™*inv(O10)*res;
% Sum of the negative of the log likelihood function (equation (3.65))
lf=lf-ff;
%======== Continuing updating the state vector and covariances ========
% Update St|t-1, in order to get the expected value of the state
% vector, given the information available up to t (equation (3.66))
S=S10(:,t)+p10*HвЂ™*inv(O10)*(Y(:,t)-y10);
% Covariance of St|t (equation (3.67))
p=p10-p10*HвЂ™*inv(O10)*H*p10;
% Forecast St+1|t (equation (3.68))
S10(:,t+1)=F*S;
% Update Pt+1|t (equation (3.69))
p10=F*p*FвЂ™+Q;
%===================Calculate the volatility curve =====================
V(1,t+1)=1/(1^2)*(H11^2*sgm1^2+H12^2*sgm2^2)*1200^2;
V(2,t+1)=1/(3^2)*(H21^2*sgm1^2+H22^2*sgm2^2)*1200^2;
V(3,t+1)=1/(12^2)*(H31^2*sgm1^2+H32^2*sgm2^2)*1200^2;
V(4,t+1)=1/(24^2)*(H41^2*sgm1^2+H42^2*sgm2^2)*1200^2;
V(5,t+1)=1/(36^2)*(H51^2*sgm1^2+H52^2*sgm2^2)*1200^2;
V(6,t+1)=1/(48^2)*(H61^2*sgm1^2+H62^2*sgm2^2)*1200^2;
V(7,t+1)=1/(60^2)*(H71^2*sgm1^2+H72^2*sgm2^2)*1200^2;
V(8,t+1)=1/(84^2)*(H81^2*sgm1^2+H82^2*sgm2^2)*1200^2;
V(9,t+1)=1/(120^2)*(H91^2*sgm1^2+H92^2*sgm2^2)*1200^2;
%================== Calculate the term premium curve ==================
T(1,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H11*sgm1)^2+(lmda2+H12*sgm2)^2))*1200;
T(2,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H21*sgm1)^2+(lmda2+H22*sgm2)^2))*1200;
T(3,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H31*sgm1)^2+(lmda2+H32*sgm2)^2))*1200;
Modelling the Term Structure of Interest Rates 99

T(4,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H41*sgm1)^2+(lmda2+H42*sgm2)^2))*1200;
T(5,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H51*sgm1)^2+(lmda2+H52*sgm2)^2))*1200;
T(6,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H61*sgm1)^2+(lmda2+H62*sgm2)^2))*1200;
T(7,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H71*sgm1)^2+(lmda2+H72*sgm2)^2))*1200;
T(8,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H81*sgm1)^2+(lmda2+H82*sgm2)^2))*1200;
T(9,t+1)=(0.5*(lmda1^2+lmda2^2)-
0.5*((lmda1+H91*sgm1)^2+(lmda2+H92*sgm2)^2))*1200;
end
%======================= Transposing matrices ========================
YT=YвЂ™;
% Yield matrix
YE1=YE(1:9,:);
% Volatility matrix
YE2=YE(10:18,:);
YE3=YE(19:19,:);
YET=YE1вЂ™;
VET=YE2;
IET=YE3вЂ™;
% Observation equation matrices
AArT=AArвЂ™;
HH1rT=HH1rвЂ™;
HH2rT=HH2rвЂ™;
L=[AArT,HH1rT,HH2rT];
%VT=VвЂ™;
%TT=TвЂ™;
S10T=S10вЂ™;
%============================== Plots ================================
% Yields
Figure(1)
plot(YET)
% Volatilities
Figure(2)
plot(VET)
% Factors
Figure(3)
plot(S10T)
% Estimated inflation
Figure(4)
plot(IET)
%============================ Saving files =========================
% Estimated Yields
save c:\matlab\V2YETgri YET -ascii;
% Estimated Inflation
save c:\matlab\V2IETgri IET -ascii;
% Factors
save c:\matlab\V2S10gri S10T -ascii;
save c:\matlab\V2loadgi L -ascii;
% Volatilities
100 Applied Quantitative Methods for Trading and Investment
save c:\matlab\V2Volgri VET -ascii;
save c:\matlab\V2tprgri TT -ascii;
This routine runs the Kalman п¬Ѓlter for any given set of parameters. In order to use it
in Matlab, an instruction must be written in the software editor comprising the name of
the п¬Ѓle and the vector of the restricted parameters between brackets, as follows:
va2fgrin([4.035,4.066,-6.465,-6.822,3.098,1.492,-0.690,-0.170,-1.780,-1.236,-0.681,
0.610,-0.083,-0.147, -1.068,0.415,-0.317,-0.079,-0.378,0.735,0.805,0.511,0.392,
-0.561,-2.794,-5.302])
Though running the Kalman п¬Ѓlter for given sets of parameters may be interesting to
assess the behaviour of the model, a more relevant exercise is the estimation of the
optimal set of parameters, which corresponds to the one that maximises the sum of the
log-likelihood function or its negative as in equation (3.65). This estimation is performed
in 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 the
estimated parameters, which is created at the end of the Matlab п¬Ѓle. The п¬Ѓle corresponding
to the Kalman п¬Ѓlter п¬Ѓle previously inserted is structured as follows:

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 r77
r88 r99 r1010 r1111 r1212 r1313 r1414 r1515 r1616 r1717 r1818 r1919 s10
s20;
global AAr HH1r HH2r A H F R Q S10 Q0 p10 vp10 z;
% defining data matrix
dat=datgerin;
global dat;
% defining parameters
para=[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 the
estimators (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 parameter
matrices (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 estimation
error of the observation equation (3.63)

Value of the log-likelihood
function (3.64)

Updating S (3.66) and P (3.67)

Forecasting the new values for
S (3.68) and P (3.69) (if there are
iterations to be done)
(if all iterations
are done)
Sum of the values of the
log-likelihood function (3.65) (if the maximum hasn't
been obtained)
(if the maximum for the
sum has been 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п¬Ѓed
models using the shorter and longer databases and for the identiп¬Ѓed model.37
The latter is inserted next. The routine starts by reading the data п¬Ѓle, which included
a п¬Ѓle with the original parameters estimated. The derivatives required are computed by
arithmetic approximation, being the increment equal to 0.00001. Then the п¬Ѓrst and the
second derivatives are computed and a matrix S containing the second derivatives. The
t-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 the
matrix S2.

% This is v2trgrin, a code for the estimation of t-ratios in a
two-factor identified Vasicek model for Germany estimated spot rates
% By Jorge Barros Luis
% defining the variables
global delta phi1 phi2 sgm1 sgm2 lmda1 lmda2 r11 r22 r33 r44 r55 r66 r77
r88 r99 s10 s20;
global AAr HH1r HH2r A H F R Q S10 Q0 p10 vp10 z;
% transposing the data column vector
Y=datgerinвЂ™;
% computing the number of observations
obs=length(Y(1,:));
para=v2pgerin;
%definition of the variations
d=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 Rates 103
dwdelta=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;
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 main
diagonal of S);
d2phi1=((v2ungrin(upphi1)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwphi1)))/d^2
d2phi2=((v2ungrin(upphi2)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwphi2)))/d^2
d2sgm1=((v2ungrin(upsgm1)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwsgm1)))/d^2
d2sgm2=((v2ungrin(upsgm2)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwsgm1)))/d^2
d2lmda1=((v2ungrin(uplmda1)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwlmda1)))/d^2
d2lmda2=((v2ungrin(uplmda2)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwlmda2)))/d^2
d2delta=((v2ungrin(updelta)-v2ungrin(para))-(v2ungrin(para)-
v2ungrin(dwdelta)))/d^2
%computation of the cross derivatives (the elements out of the main
diagonal of S);
dph1ph2=(v2ungrin(uph1uph2)-v2ungrin(uph1dph2)-
v2ungrin(dph1uph2)+v2ungrin(dph1dph2))/4*d^2
dph1sg1=(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^2
dph1lm1=(v2ungrin(uph1ulm1)-v2ungrin(uph1dlm1)-
v2ungrin(dph1ulm1)+v2ungrin(dph1dlm1))/4*d^2
dph1lm2=(v2ungrin(uph1ulm2)-v2ungrin(uph1dlm2)-
v2ungrin(dph1ulm2)+v2ungrin(dph1dlm2))/4*d^2
dph1delt=(v2ungrin(uph1udel)-v2ungrin(uph1ddel)-
v2ungrin(dph1udel)+v2ungrin(dph1ddel))/4*d^2
dph2sg1=(v2ungrin(uph2usg1)-v2ungrin(uph2dsg1)-
v2ungrin(dph2usg1)+v2ungrin(dph2dsg1))/4*d^2
dph2sg2=(v2ungrin(uph2usg2)-v2ungrin(uph2dsg2)-
v2ungrin(dph2usg2)+v2ungrin(dph2dsg2))/4*d^2
dph2lm1=(v2ungrin(uph2ulm1)-v2ungrin(uph2dlm1)-
v2ungrin(dph2ulm1)+v2ungrin(dph2dlm1))/4*d^2
dph2lm2=(v2ungrin(uph2ulm2)-v2ungrin(uph2dlm2)-
v2ungrin(dph2ulm2)+v2ungrin(dph2dlm2))/4*d^2
dph2delt=(v2ungrin(uph2udel)-v2ungrin(uph2ddel)-
v2ungrin(dph2udel)+v2ungrin(dph2ddel))/4*d^2
dsg1sg2=(v2ungrin(usg1usg2)-v2ungrin(usg1dsg2)-
v2ungrin(dsg1usg2)+v2ungrin(dsg1dsg2))/4*d^2
dsg1lm1=(v2ungrin(usg1ulm1)-v2ungrin(usg1dlm1)-
v2ungrin(dsg1ulm1)+v2ungrin(dsg1dlm1))/4*d^2
dsg1lm2=(v2ungrin(usg1ulm2)-v2ungrin(usg1dlm2)-
v2ungrin(dsg1ulm2)+v2ungrin(dsg1dlm2))/4*d^2;
dsg1delt=(v2ungrin(usg1udel)-v2ungrin(usg1ddel)-
v2ungrin(dsg1udel)+v2ungrin(dsg1ddel))/4*d^2
dsg2lm1=(v2ungrin(usg2ulm1)-v2ungrin(usg2dlm1)-
v2ungrin(dsg2ulm1)+v2ungrin(dsg2dlm1))/4*d^2
dsg2lm2=(v2ungrin(usg2ulm2)-v2ungrin(usg2dlm2)-
v2ungrin(dsg2ulm2)+v2ungrin(dsg2dlm2))/4*d^2
dsg2delt=(v2ungrin(usg2udel)-v2ungrin(usg2ddel)-
v2ungrin(dsg2udel)+v2ungrin(dsg2ddel))/4*d^2
dlm1lm2=(v2ungrin(ulm1ulm2)-v2ungrin(ulm1dlm2)-
v2ungrin(dlm1ulm2)+v2ungrin(dlm1dlm2))/4*d^2
dlm1delt=(v2ungrin(ulm1udel)-v2ungrin(ulm1ddel)-
v2ungrin(dlm1udel)+v2ungrin(dlm1ddel))/4*d^2
dlm2delt=(v2ungrin(ulm2udel)-v2ungrin(ulm2ddel)-
v2ungrin(dlm2udel)+v2ungrin(dlm2ddel))/4*d^2
%Matrix S
S=1/obs*[d2phi1 dph1ph2 dph1sg1 dph1sg2 dph1lm1 dph1lm2 dph1delt;
dph1ph2 d2phi2 dph2sg1 dph2sg2 dph2lm1 dph2lm2 dph2delt; dph1sg1 dph2sg1
d2sgm1 dsg1sg2 dsg1lm1 dsg1lm2 dsg1delt; dph1sg2 dph2sg2 dsg1sg2 d2sgm2
dsg2lm1 dsg2lm2 dsg2delt; dph1lm1 dph2lm1 dsg1lm1 dsg2lm1 d2lmda1
dlm1lm2 dlm1delt; dph1lm2 dph2lm2 dsg1lm2 dsg2lm2 dlm1lm2 d2lmda2
dlm2delt; dph1delt dph2delt dsg1delt dsg2delt dlm1delt dlm2delt
d2delta];
%T-ratios
S2=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 RESULTS
Before the estimation results, it is worthwhile to present the most signiп¬Ѓcant stylised
facts concerning the data. The properties of the German yield curve are summarised in
Tables 3.1 and 3.2. A number of features are worth noting. Firstly, between 1986 and
1998, the term structure is negatively sloped at the short end, in contrast with the more
familiar concave appearance observed for the USA market (see Backus et al. (1997)).
Secondly, yields are very persistent, with monthly autocorrelations above 0.98 for all
maturities.38 Thirdly, yields are highly correlated along the curve, but correlation is not
equal to one, with lower correlations obtained for the ends of the yield curve. This
suggests that non-parallel shifts of the yield curve are important. Therefore, one-factor
models 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.39
Figure 3.6 (simple test) and Figure 3.7 (forward regressions) show the results of the tests

Table 3.1 Properties of German government bond yields in 1986вЂ“1988

Maturity 1 3 12 24 36 48 60 84 120
Mean 5.732 5.715 5.681 5.823 6.020 6.203 6.359 6.587 6.793
St. Dev. 2.267 2.224 2.087 1.882 1.686 1.524 1.398 1.228 1.095
Skewness 0.450 0.449 0.490 0.522 0.519 0.487 0.432 0.282 0.049
в€’1.258 в€’1.267 в€’1.139 в€’1.051 в€’0.975 в€’0.871 в€’0.737 в€’0.426
Kurtosis 0.001
Autocorrelation 0.991 0.992 0.991 0.990 0.989 0.989 0.988 0.987 0.983

Normality Tests

Maturity 1 3 12 24 36 48 60 84 120
П‡ 2 (2) 15.5558 15.6717 14.6832 14.2669 13.1898 11.1065 8.3923 3.2515 0.0627
P (X > x) 0.0004 0.0004 0.0006 0.0008 0.0014 0.0039 0.0151 0.1968 0.9691

Correlation matrix

y1 1.000 0.998 0.969 0.936 0.913 0.891 0.867 0.816 0.743
y3 1.000 0.982 0.955 0.934 0.912 0.889 0.839 0.765
y12 1.000 0.993 0.980 0.964 0.944 0.898 0.829
y24 1.000 0.996 0.986 0.972 0.935 0.875
y36 1.000 0.997 0.988 0.961 0.911
y48 1.000 0.997 0.980 0.940
y60 1.000 0.992 0.962
y84 1.000 0.989
y120 1.000

38
Interest rates are close to being non-stationary.
39
This routine is not included on the CD-Rom, as this is a trivial exercise.
Modelling the Term Structure of Interest Rates 107

Table 3.2 Properties of German government bond yields in 1972вЂ“1988

Maturity 12 24 36 48 60 72 84 96 120
Mean 6.348 6.609 6.856 7.051 7.202 7.321 7.414 7.487 7.594
St. Dev. 2.290 2.053 1.891 1.770 1.674 1.598 1.535 1.483 1.401
Skewness 0.545 0.349 0.224 0.151 0.108 0.084 0.075 0.077 0.112
в€’0.513 в€’0.671 в€’0.677 в€’0.636 в€’0.575 в€’0.495 в€’0.397 в€’0.281 в€’0.006
Kurtosis
Autocorrelation 0.981 0.985 0.985 0.985 0.985 0.985 0.985 0.984 0.981

Normality Tests

Maturity 12 24 36 48 60 72 84 96 120
П‡ 2 (2) 19.28 12.44 8.76 6.59 5.01 3.64 2.39 1.37 0.67
P (X > x) 0.000 0.002 0.013 0.037 0.082 0.162 0.302 0.505 0.715

Correlation matrix

y12 1.000 0.986 0.964 0.942 0.919 0.896 0.874 0.853 0.812
y24 1.000 0.993 0.979 0.962 0.943 0.924 0.906 0.870
y36 1.000 0.996 0.986 0.973 0.958 0.943 0.912
y48 1.000 0.997 0.990 0.980 0.968 0.943
y60 1.000 0.998 0.992 0.984 0.964
y72 1.000 0.998 0.994 0.979
y84 1.000 0.999 0.989
y96 1.000 0.995
y120 1.000

8.0

7.5

7.0
%

6.5

6.0

5.5

5.0
0 12 24 36 48 60 72 84 96 108 120
Time to settlement (in months)

Figure 3.6 Simple test of the pure expectations theory of interest rates. Forward rate average
curve in 1986вЂ“1998
108 Applied Quantitative Methods for Trading and Investment

1.10
1.10

1.05
1.05

1.00
1.00
Beta

0.95
0.95

0.90
0.90

0.85
0.85
0 12 24 36 48 60 72 84 96 108 120
Time to settlement (in months)

Figure 3.7 Test of the expectations theory of interest rates. Forward regression coefп¬Ѓcient in
1986вЂ“1998

Table 3.3 Parameter estimates in the forward regressions

M 3 12 24 36 48 60 84 120
ОІ 0.953 0.965 0.975 0.980 0.981 0.981 0.980 0.979
Пѓ (ОІ) 0.029 0.022 0.015 0.013 0.012 0.012 0.013 0.014
в€’0.003
О± 0.005 0.020 0.029 0.034 0.038 0.043 0.046
Пѓ (О±) 0.007 0.019 0.025 0.030 0.033 0.036 0.040 0.043

of the expectations theory of the term structure, in line with equations (3.33) and (3.34).
In Table 3.3, the parameter estimates are exhibited.
The pure expectations theory is easily rejected: as shown in Figure 3.6 and Table 3.3,
average one-period short-term forward rates vary with maturity, which contradicts equa-
tion (3.33) with n = 0.40 However, as shown in Figure 3.7, forward regressions gen-
erate slope coefп¬Ѓcients close to one for all maturities, with relatively small standard
errors,41 suggesting that the assumption of constant term premiums might be a reasonable
approximation.
The results42 of the term structure estimation are shown in Figure 3.8a and b (average
yield curves), Figure 3.9a and b (volatility curves), Figure 3.10a and b (term premium
curves), Figure 3.11a and b (one-period forward curves), Figure 3.12a and b (expected
short-term interest rate curves), Figure 3.13a and b (time-series yields), Figure 3.14a and b
(time-series inп¬‚ation), Figure 3.15a and b (factor loadings) and Figure 3.16aвЂ“f (time-series
factors). The parameters and their standard errors are reported in Tables 3.4 and 3.5.43

40
In the steady state, it is expected that short-term interest rates remain constant. Thus the one-period forward
curve should be п¬‚at under the absence of risk premium.
41
NeweyвЂ“West standard errors.
42
Many of the charts which follow need to be viewed in colour to be fully understood. Each of the following
п¬Ѓgures are included as an Excel п¬Ѓle with suitably titled п¬Ѓlenames on the CD-Rom.
43
The inп¬‚ation rate used in the identiп¬Ѓed models was obtained from Datastream.
Modelling the Term Structure of Interest Rates 109

8.0

7.5

7.0
%

6.5

6.0

5.5

5.0
0 12 24 36 48 60 72 84 96 108 120
Term to maturity (in months)

Observed 2f non-id. 3f non-id. 2f-ident. 2f-ident.2

(a)

8.0

7.5

7.0
%

6.5

6.0

5.5

5.0
0 12 24 36 48 60 72 84 96 108 120
Term to maturity (in months)

Observed 2f non-id. 2f ident.2 2f ident.

(b)

Figure 3.8 Average yield curves: (a) 1986вЂ“1998 and (b) 1972вЂ“1998

According to Figures 3.8a and b, 3.9a and b, all estimates reproduce very closely both the
average yield and the volatility curves, though worse results are obtained for 1986вЂ“1998
when the second factor is identiп¬Ѓed with inп¬‚ation as in equation (3.55) or equation (3.56).44
This result must be associated with the link between the behaviour of the second factor and
the inп¬‚ation, which implies a worse п¬Ѓtting for the long-term interest rates.

44
The results with the alternative identiп¬Ѓed model (in equation (3.56)) are labelled вЂњ2f-ident.2вЂќ.
110 Applied Quantitative Methods for Trading and Investment

3.0

2.5
Standard deviation of yields

2.0

1.5

1.0

0.5

0.0
0 12 24 36 48 60 72 84 96 108 120
Term to maturity (in months)

Observed 2f non-id. 3f non-id. 2f ident. 2f ident.2

(a)

3.0

2.5
Standard deviation of yields

2.0

1.5

1.0

0.5
0 12 24 36 48 60 72 84 96 108 120
Term to maturity (in months)

Observed 2f non-id. 2f ident. 2f ident.2

(b)

Figure 3.9 Volatility curves: (a) 1986вЂ“1998 and (b) 1972вЂ“1998

Concerning the term premium and the one-period forward, Figures 3.10a and b, 3.11a
and b show again that the results obtained differ in the shorter sample, depending on using
identiп¬Ѓed or non-identiп¬Ѓed models. The estimates obtained with the identiп¬Ѓed model in
equation (3.55) point to lower risk premium in the maturities between 2 and 7 years,
while the risk premium is higher at both ends of the curve. This model still presents an
estimate for the 8-year risk premium around 1.7 in both samples, though it converges
Modelling the Term Structure of Interest Rates 111

2.5

2.0

1.5
%

1.0

0.5

0.0

в€’0.5
0 12 24 36 48 60 72 84 96 108 120
Term to maturity (in months)

2f non-id. 3f non-id. 2f ident. 2f ident.2

(a)

2.5

2.0

1.5
%

1.0

0.5

0.0

 << стр. 5(всего 19)СОДЕРЖАНИЕ >>