0% found this document useful (0 votes)
14 views37 pages

Further Results With OU and CIR Processes

Uploaded by

Tutul Malakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views37 pages

Further Results With OU and CIR Processes

Uploaded by

Tutul Malakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Calibration of Stochastic Convenience Yield Models

For Crude Oil Using the Kalman Filter

A.Krul
Adriaan.Krul@INGbank.com
tw1249266
Literature report

10-12-07 20-2-2008
2
Contents

1 Introduction 5
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Stochastic convenience yield model following an Ornstein-Uhlenbeck process 7


2.1 Mean and variance of the Ornstein-Uhlenbeck process . . . . . . . . . . . . . . . . . . . . 7
2.2 Market price of risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 The value of a future delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Price valuation of a European call option . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 Stochastic convenience yield model following a Cox-Ingersoll-Ross process 13


3.1 Mean and variance of the CIR process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 The logprice and inserting the market price of risk . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Partial differential equation for the future prices . . . . . . . . . . . . . . . . . . . . . . . 15

4 Kalman Filter 19
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 Kalman Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3 Introductory example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3.1 Simulation results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3.2 How to choose R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5 The Kalman Filter for the Ornstein-Uhlenbeck process 25


5.1 Iterative procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.2 Numerical results for the Ornstein-Uhlenbeck process . . . . . . . . . . . . . . . . . . . . . 27
5.2.1 Setting up the calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.2.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.2.3 Results for different number of contracts . . . . . . . . . . . . . . . . . . . . . . . . 28
5.2.4 Estimated future prices versus observered future prices . . . . . . . . . . . . . . . . 28
5.2.5 Filtered convenience yield versus implied convenience yield . . . . . . . . . . . . . 29
5.2.6 Innovations vt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2.7 Parameter explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.8 Implementation issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.9 Kalman Forecasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

6 The Kalman Filter model for the Cox-Ingersoll-Ross process. 33

7 Conclusion 35
7.1 Further research . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4 CONTENTS
Chapter 1

Introduction

1.1 Introduction
A future contract is an agreement between two parties to buy or sell an asset at a certain time in the
future for a certain price. Nowadays, traders calibrate the so-called convenience yield (CY), δt , via market
data every two days, using the future contract. Convenience yield is the benefit or premium associated
with holding an underlying product or physical good, rather than the contract or derivative product.
Sometimes, due to irregular market movements such as an inverted market (this is when the short-term
contract prices are higher than the long-term contracts), the holding of an underlying good or security
may become more profitable than owning the contract or derivative instrument, due to its relative scarcity
versus high demand.
An example would be purchasing physical bales of oil rather than future contracts. Should their be a
sudden shock-situation wherein the demand for oil increases, the difference between the first purchase
price of the oil versus the price after the shock would be the convenience yield. The market shows
however that the CY behaves stochastically and has a mean-reverting property, see e.g. [5]. The CY
may therefore be modelled by an Ornstein-Uhlenbeck (OU) process. The disadvantage of this process is
that it allows for negative CY which can result in cost and carry arbitrage possibilities. To prevent this
from happening we assume that the CY follows a Cox-Ingersoll-Ross (CIR) model. For both processes,
the spot price follows a geometrical brownian motion.
For commodities, the spot prices and the CY can not be observered directly from the market. To model
both stochastic processes (OU and CIR), the non-observability of these state variables is difficult. Since
the future prices of commodities are widely observered and traded on the market we use a method that
links these actual observations with the latent state variables. This method is known as the Kalman Filter,
(KF). The main idea of the (KF) is to use observable (futures) variables to reconstitute the value of the
non-obsvervable (spot prices and CY). We use futures of light crude oil ranging for the period from
01-02-2002 until 25-01-2008.
For applying the Kalman Filter, we assume an affine form for the closed form solution of the future prices
for both the OU and the CIR process. By assuming this, solving the stochastic differential equation of
both processes is a lot easier and having the closed form solution of the future prices will make the use
of the KF considerably easier.
The aim of this thesis is to implement the KF for both OU and CIR and compare the results with the
market data. Other commodities are numerically tested and we will try to price options on commodities
using this method. The outline of this report is as follows; in Chapter 2 and 3 analytical results are given
for the OU and CIR processes (resp.). In Chapter 4, the KF is explained in detail and it starts with an
introductory example. Chapter 5 applies the KF to the OU process and discusses the numerical results.
In Chapter 6 the KF is set up for the CIR process, but not yet tested numerically. The report ends with
a conclusion and further research.
6 Introduction
Chapter 2

Stochastic convenience yield model


following an Ornstein-Uhlenbeck
process

In this chapter analytical results are given for the stochastic CY when it follows an Ornstein-Uhlenbeck
process. The assumption is that the spot price St follows a geometrical Brownian motion, i.e.,

dSt = (µ − δt )St dt + ηSt dWt , (2.1)

where µ is the drift term, η is the volatility term, and Wt a standard Brownian motion. The form of the
convenience yield (δt ) is a result of the studies of Gibson and Schwartz (see [5]) where they find empirical
evidence that the convenience yield will have a mean-reverting property, i.e.,

dδt = k(α − δt )dt + σdZt . (2.2)

In (2.2), α is the long range mean to which δt tends to revert, k the speed of adjustment, σ the volatility
term and Zt a standard Brownian motion. Here dWt dZt = ρdt. The solution of (2.1) is given by
( Z T )
1 2
ST = St exp (µ − η )(T − t) + η dWs , (2.3)
2 t

and the solution of (2.2) is


Z T
δT = θδt + (1 − θ)α + σe−kT eks dZs , (2.4)
t

where θ = e−k(T −t) .

2.1 Mean and variance of the Ornstein-Uhlenbeck process


Apply Ito’s lemma on f (δT , t) = δT ekt which results in

df (δt , t) = kδt ekt dt + ekt dδt


= ekt kαdt + σekt dZt .

This implies
Z t Z t
kt ks
δt e = δ0 + kα e ds + σ eks dZs .
0 0
8 Stochastic convenience yield model following an Ornstein-Uhlenbeck process

Rearranging and taking expectation yields


E[δt ] = δ0 e−kt + α(1 − e−kt ) = δ0 θ + α(1 − θ),
where θ = e−kt . For the variance we calculate the covariance matrix by applying the Ito Isometry
Cov(δs , δt ) = E[(δs − E[δs ])(δt − E[δt ])]
Z s Z t
= E[σ e−k(u−s) dZu σ e−k(v−t) dZv ]
0 0
Z s Z t
2 −k(s+t) ku
= σ e E[ e dZu ekv dZv ]
0 0
σ 2 −k(s+t) 2k(min(s,t))
= e (e − 1).
2k
2
 2

For s = t this gives Var[δt ] = σ2k (1 − θ2 ). We conclude that δt is N θδt + (1 − θ)α, σ2k (1 − θ2 ) .

2.2 Market price of risk


For the interest rate we do not have to build in a stochastic model so we keep r deterministic (constant)
[4]. Since the CY is non-traded, the convenience yield risk cannot be hedged and it will have a market
price or risk, λδ associated with it. To see how this is inserted in (2.1) and (2.2), consider the standard
geometrical brownian motion
dSt
= µdt + ηdWt ,
St
and taking at both sides the expectation and rearranging to get
1 dSt
µ= E[ ].
dt St
We see that µ is the expected return per unit time of a stock St in an economy where the only source of
risk is the Brownian motion. We can write
µ = r − δt + b,
where r denotes the risk-free rate and b the risk premium. Since we assume that η is non-zero we define
b
λ=
η
to be the risk premium expected by investors per unit of volatility. It is usually refered to as the market
price of equity risk per unit of η. We now have
µ + δt − r
µ = r − δt + λη and so λ = .
η
Inserting this in (2.1) we get
dSt µ + δt − r dSt
= µdt + η(dWt − ( )dt) ⇒ = (r − δt )dt + ηdW̃t , (2.5)
St η St
where W̃t is the standard Brownian motion under the risk-neutral measure. For (2.2) it is easily shown
that
σλ
dδt = k((α − ) − δt )dt + σdZ̃t ,
k
holds. Again, dZ̃t is the standard brownian motion under the risk-neutral measure and dZ̃t dW̃t = ρdt as
before. Now we have the system of two joint stochastic processes
 dSt = (r − δt )dt + ηdW̃t ,

St (2.6)
dδt = k((α − σλ −

k ) δ t )dt + σd Z̃t .
Note that this derivation is based on the Girsanov theorem.
2.3 The value of a future delivery 9

2.3 The value of a future delivery


Define YT = Y (T, ST , δT ) to be the payoff at time T . The discounted expected value of YT at time t is
given by

Vt [YT ] := e−r(T −t) E[YT ]. (2.7)

From (2.5) we get


T T
µ−r
Z Z
1
dWs = dW̃s − (T − t) − (XT − Xt ), (2.8)
t t η η
Rt
where Xt = 0 δs ds.
From (2.2) we get
Z T Z T Z T Z T
dδs = δT − δt = kαt − k δs ds + σ dZs = kα(T − t) − k(XT − Xt ) + σ dZs . (2.9)
t t t t

Now insert (2.4) to get


Z T Z T
1 σ σ −kT
XT = Xt + (1 − θ) (δt − α) + α(T − t) + dZs − e eks dZs . (2.10)
k k t k t

For the future price we consider the case YT ≡ ST and we compute Vt [ST ]. The current value of a claim
on a future delivery of the commodity on the future date t is
 
1 1 1
Vt [ST ] = St exp −α + (σλ − σηρ) + ( )2 σ 2 (T − t)
k 2 k
 
1 1 1
− δt − α + (σλ − σηρ) + ( )2 σ 2 (1 − θ)
k k k
2

1 1 σ
+ ( )2 (1 − θ2 ) . (2.11)
2 k 2k
Proof. From (2.7) and (2.3) we get
 Z T 
−r(T −t) 1 2
e ST = St exp (µ − r − η )(T − t) + η dWs . (2.12)
2 t

Multiplying (2.8) with η, it follows together with (2.10)


Z T Z T
1 1 1
η Ws = −(T − t)(µ − r + α − σλ) + (α − δt + σλ)(1 − θ) + η dW̃s
t k k k t
Z T Z T
1 1
− σ dZs + σe−kT eks dZs .
k t k t
(2.13)

Now we can write (2.12) as follows



−r(T −t) 1 1 1
e ST = St exp −( η 2 + α − σλ)(T − t) + (α − δt )
2 k k
Z T Z T
1 −kT T
Z 
1 1
− σλ)(1 − θ) + η dW̃s − σ dZ̃s + σe dZ̃s
k t k t k t
= St ez . (2.14)

From basic stochastic calculus it follows

µ̃ = E[z]
1 1 1 1
= −( η 2 + α − σλ)(T − t) + (α − δt − σλ)(1 − θ). (2.15)
2 k k k
10 Stochastic convenience yield model following an Ornstein-Uhlenbeck process

For calculating Var[z] we notice that for a general process g ∈ L2 [t, T ] it follows
!2 
 Z T Z T
E g(s)dWs = E[g(s)2 ]ds.
t t

Using this we can calculate the following expectations


!
 Z Z T T Z T
E η2 dW̃s dW̃s = η2 E[12 ]dt = η 2 (T − t) (2.16)
t t t
Z T !2 
σ2 T σ2
 Z
1
E σ dZ̃s = 2
E[12 ] = 2 (T − t) (2.17)
k t k t k
!2
1 −kT T ks σ −2kT T
 Z   2 Z 
2ks
E e e dZ̃s = e E[e ]ds
k t k2 t

σ 2 −2kT 1 2kT 1 2kt


2
e [ e − e ] =
k 2k 2k
σ2 1
= 2 2k
[1 − θ2 ] (2.18)
! ! k
 Z T Z T
1 σ
E η dW̃s σ dZ̃s = η ρ(T − t) (2.19)
t k t k
 Z T ! !
1 −kT T ks
Z  Z T
ησ
E η dW̃s σe e dZ̃s = e−kT ρ E[eks ]ds
t k t k t
ησρ 1 kT
= e−kT [e − ekt ]
k k
ησρ
= (1 − θ) (2.20)
! ! k2
 Z T Z T Z T
1 1 −kT 1 2 −kT
E σ dZ̃s σe eks dZ̃s = σ e ρ E[eks ]ds
k t k t k2 t
1 2 −kT 1 kT
= (σ e )ρ (e − ekt )
k2 k
σ2 ρ
= (1 − θ). (2.21)
k3
Finally we get

σ̃ 2 = E[(z 2 )] − (E[z])2
1 1
= (η 2 − 2 σηρ + 2 σ 2 )(T − t)
k k
1 1
+ 2( 2 σηρ − 3 σ 2 )(1 − θ)
k k
1 σ2
+ (1 − θ2 ), (2.22)
k 2 2k
where θ = e−k(T −t) as before. From the standard formula of the expected value of a lognormal random
variable we get
 
1
Vt [ST ] = St exp µ̃ + σ̃ 2 . (2.23)
2
2.4 Price valuation of a European call option 11

The future price of a contract on a commodity with time to maturity τ = T − t is given by

F (S, δ, τ ) := erτ Vt [ST ]. (2.24)

This follows from the absence of risk-free arbitrage opportunities, i.e. we must have

Vt [ST − F ] = 0. (2.25)

In order to find the PDE to which F (S, δ, τ ) satisfies we use the Feynman-kač theorem.

Theorem 2.1. Feynman-Kač


Suppose the underlying processes y1 (t), y2 (t), .., yn (t) follow the stochastic differential equation

dyi = µi (y1 , y2 , ..yn , t)dt + σi (y1 , y2 , .., yn , t)dWi .

Then the function

g(y1 , y2 , .., yn , t) = Ey1 ,y2 ,..,yn ,t [f (y1 (T ), .., yn (T ))]

is given by the solution of the partial differential equation


n n
∂g X ∂g 1 X ∂2g
+ µi + ρij σi σj = 0,
∂t i=1 ∂yi 2 i,j=1 ∂yi ∂yj

subject to

g(y1 , y2 , .., yn , T ) = f (y1 , y2 , .., yn ),

where ρij = Cov(dWi , dWj )/dt.

F (S, δ, τ ) satisfies the PDE

 1 η 2 S 2 FSS + ρησSFSδ + 1 σ 2 Fδδ + (r − δ)SFS + (k(α − δ) − λ)Fδ − Fτ = 0,



2 2 (2.26)
F (S, δ, 0) = S0 .

A similar result exists for V (S, δ, t) := Vt [YT ]. The V (S, δ, t) satisfies the PDE

 1 η 2 S 2 VSS + ρησSVSδ + 1 σ 2 Vδδ + (r − δ)SVS + (k(α − δ) − λ)Vδ − rVτ = 0,



2 2 (2.27)
V (S, δ, T ) = Y (S, δ).

2.4 Price valuation of a European call option


The value of a European call option at time t is given by

Vt [(ST − K)+ ] = Vt [ST ]N [d1 ] − e−r(T −t) KN [d2 ], (2.28)

where N [·] is the standard cumulative distribution function and we define

ln(Vt [ST ]/K) + r(T − t) + 12 σ̃ 2


d1 = ,
σ̃
ln(Vt [ST ]/K) + r(T − t) − 12 σ̃ 2
d2 = ,
σ̃
where σ̃ is given by (2.22).
12 Stochastic convenience yield model following an Ornstein-Uhlenbeck process

Proof. Apply (2.7) to (2.28) to obtain

Vt [(ST − K)+ ] = e−r(T −t) Et [(ST − K)+ ]

and by using (2.14) we get

Vt [(ST − K)+ ] = E[(ST ez − e−r(T −t) K)+ ].

Since z is N (µ̃, σ̃) we get

ln(ST /K) + r(Tt ) + µ̃ + σ̃ 2


   
+ 1
Vt [(ST − K) ] = exp µ̃ + σ̃ St N
2 σ̃
 
ln(ST /K) + r(Tt ) + µ̃
− exp {−r(T − t)} N .
σ̃

Together with (2.23) the result immediately follows.


Chapter 3

Stochastic convenience yield model


following a Cox-Ingersoll-Ross
process

In this chapter, instead of (2.2) we assume that the convenience yield follows a Cox-Ingersoll-Ross (CIR)
process and where the spot price follows a geometrical brownian motion with a time-varying volatility,
which is proportional to the square root of the instantaneous convenience yield level, i.e.,

 dSt = (µ(·) − δ )dt + η δ dW ,


 p
t t t
St (3.1)

dδt = k(α − δt )dt + σ δt dZt ,

In (3.1), S is the price of the underlying, δ is the CY, µ is the drift term, η is the volatility term of dS
St ,
t

Wt a standard Brownian motion, α is the long range mean to which δt tends to revert, k the speed of
adjustment, σ the volatility term of dδt , and Zt a standard Brownian motion. Here dWt dZt = ρdt. The
reason why we assume that the CY follows a CIR process is the nonnegativity. A negative CY would
make the forward prices go up at more than the interest rate and provide some kind of cash and carry
arbitrage through buying the spot commodity and selling a forward. The CIR process excludes negative
CY.

3.1 Mean and variance of the CIR process


The integral equation for δt is given by
Z t Z tp
δt = δ0 + k (α − δu )du + σ δu dZu .
0 0

Taking expectations on both sides and differentiating yields

d d kt d
E[δt ] = k(α − E[δt ]) ⇒ e E[δt ] = ekt [kE[δt ] + E[δt ]] = ekt kα.
dt dt dt
This leads to
Z t
kt
e E[δt ] − δ0 = kα eku du = α(ekt − 1) ⇒ E[δt ] = α + e−kt (δ0 − α) = e−kt δ0 + (1 − e−kt )α.
0

Remark. We see that if δ0 = α then E[δt ] = α ∀t. If δ0 6= α, then δt exhibits mean reversion, i.e.

limt→∞ E[δt ] = α.
14 Stochastic convenience yield model following a Cox-Ingersoll-Ross process

For the variance we calculate first dδt2 via Ito. Define f (x) = x2 . We have

dδt2 = df (δt )
1
= f 0 (δt )dδt + f 00 (δt )dδt dδt
2 p p
= 2δt [k(α − δt )dt + σ δt dZt ] + [k(α − δt )dt + σ δt dZt ]2
3/2
= 2αkδt dt − 2kδt2 dt + 2σδt dZt + σ 2 δt dt
3/2
= (2kα + σ 2 )δt dt − 2kδt2 dt + 2σδt dZt .

This leads to
Z t Z t Z t
δt2 = δ02 + (2kα + σ ) 2
δu du − 2k δu2 du + 2σ δu3/2 dZu .
0 0 0

Taking expectation on both sides and differentiating with respect to t yields

d
E[δt2 ] = (2kα + σ 2 )E[δt ] − 2kE[δt2 ].
dr
From this we get

d 2kt 2 d
e E[δt ] = e2kt [2kE[δt2 ] + E[δt2 ]]
dt dt
= e2kt (2kα + σ 2 )E[δt ].

It follows that
ασ 2 σ2 σ2 σ2 α
E[δt2 ] = + α2 + (δ0 − α)( + 2α)e−kt + (δ0 − α)2 e−2kt + ( δ0 )e−2kt .
2k k k k 2
We finally have

Var[δt ] = E[δt2 ] − (E[δt ])2


σ2 σ2
= α (1 − e−kt )2 + δ0 (e−kt − e−2kt ). (3.2)
2k k

3.2 The logprice and inserting the market price of risk


By defining x = ln St and via Ito, the log price can be derived.
 
1 1 2 2 1 p 1
dx = (µ(·) − δt )St + 0 + η δt St (− 2 ) dt + η δt St dWt
St 2 St St
 
1 2 p
= (µ(·) − δt ) − η δt dt + η δt dWt . (3.3)
2

Again via the same explanation given in chapter 1 we insert the market price of risk into (3.3). This
leads to the two joint stochastic process

 dSt = (r − δt )dt + η δt dW̃t ,


 p
St (3.4)

dδt = (k(α − δt ) − λδt )dt + σ δt dZ̃t ,

The log price process is given by


   
1 p
dx = r − 1 + η 2 δt dt + η δt dW̃t . (3.5)
2
3.3 Partial differential equation for the future prices 15

3.3 Partial differential equation for the future prices


Following the approach as discussed in Section 2.5, we have the following PDE for the future price
F (S, δ, τ )

 1 η 2 δS 2 FSS + ρησδSFSδ + 1 σ 2 δFδδ + (r − δ)SFS + (k(α − δ) − λ)Fδ − Fτ = 0,



2 2 (3.6)
F (S, δ, 0) = S0 .

Assuming (see e.g. [2]) this PDE has an affine form solution

 F (S, δ, τ ) = SeA(τ )−B(τ )δ ,
(3.7)
 A(0) = 0, B(0) = 0.

To find B(τ ) and A(τ ) we notice that (by substituting (3.7) into (3.6))

1 2 2
σ B + (k − ρησ)B − 1 + Bτ = 0,
2
r + (λ − kα)B − Aτ = 0.

For simplicity first write a1 = 12 σ 2 and a2 = k − ρησ which leads to f (B) = Bτ = −a1 B 2 − a2 B + 1.
Now we want to factorize the function f (B).

f (B) a2 1
= B2 + B − = (B + )(B − γ).
−a1 a1 a1

a2 1
From this we get that ( − γ) = a1 and γ = a1 . From these two relations it follows that we have to solve

a1 γ 2 + a2 γ − 1 = 0.

This gives
p
a2 a22 + 4a1
γ1,2 = − ±
2a1 2a1
−k2 ± k1
= , (3.8)
2a1

where k1 and k2 are given by (3.15). From this point it is assumable that both γ’s should work. For
convenience of the reader we check this below. We have

Bτ = −a1 (B + )(B − γ) = 0
1
dB + a1 dτ = 0
(B + )(B − γ)
 
1 −1 1
+ dB + a1 dτ = 0
γ+ B+ B−γ
1 1
[−ln|B + | + ln|B − γ|] + τ = c
γ+ a1
 
|B − γ| γ+
ln = − τ + (γ + )c
|B + | a1
γ+
(c̃e− a1 τ
+ γ)
B(τ ) = ,
− γ+
a τ
1 − c̃e 1
16 Stochastic convenience yield model following a Cox-Ingersoll-Ross process

with initial condition B(0) = 0 we get that c̃ = − γ . Substituting c̃ and calculating for γ1 (which refers
to the plus sign) gives
γ+
γ(1 − e− a1 τ
)
B(τ ) = γ+
γ − a1 τ
1+ e
γ+
1 − e− a1 τ
= −
γ+
τ
+γe a1

γ+
1 − e− a1 τ
= γ+
k2 + a1 (1 + e− a1 τ

− γ+
a1 τ
1−e
= γ+
k2 + a1 ( −k2a
2 +k1
1
(1 + e− a1 τ
))
− γ+
a1 τ
2(1 − e )
=
− γ+ γ+
2k2 − k2 + k1 − k2 e a τ
1 + k1 e− a1 τ

γ+
2(1 − e− a1 τ
)
= γ+ . (3.9)
k2 + k1 + (k1 − k2 )e− a1 τ

Now calculate
−k2 +k1 k −k2 +k1
( + 2+ )τ
2a1 a1 2a1
− γ+
a τ −
e 1 = e a1

= e−k1 τ . (3.10)

Substituting (3.10) into (3.9) results in

2(1 − e−k1 τ )
B(τ ) = (3.11)
k1 + k2 + (k1 − k2 )e−k1 τ

Now substituting c̃ and calculating for γ2 (which refers to the plus sign) gives
γ+
γ(1 − e− a1 τ
)
B(τ ) = γ+
γ − a1 τ
1+ e
γ+
1 − e− a1 τ
= −
γ+
τ
+γe a1

γ+
1 − e− a1 τ
= γ+
k2 + a1 (1 + e− a1 τ

− γ+
a1 τ
1−e
= γ+
k2 + a1 ( −k2a
2 −k1
1
(1 + e− a1 τ
))
− γ+
a1 τ
2(1 − e )
=
− γ+ γ+
2k2 − k2 − k1 − k2 e a τ
1 − k1 e− a1 τ

γ+
2(1 − e− a1 τ
)
= γ+ .
k2 − k1 + (−k1 − k2 )e− a1 τ

Now calculate
−k2 −k1 k −k2 −k1
( + 2+ )τ
2a1 a1 2a1
− γ+
a τ −
e 1 = e a1

= ek1 τ . (3.12)
3.3 Partial differential equation for the future prices 17

Substituting (3.12) into (3.9) results in

2(1 − ek1 τ ) −e−k1 τ


B(τ ) =
−k1 + k2 + (−k1 − k2 )e−k1 τ −e−k1 τ
2(1 − e−k1 τ )
= , (3.13)
k1 + k2 + (k1 − k2 )e−k1 τ

where it is shown that both γ’s satisfy. Accordingly


Z T
A(τ ) = rτ + (λ − kα) Bq dq, (3.14)
t

where
T
(k1 + k2 )ek1 τ + k1 − k2
Z  
2
Bq dq = ln (3.15)
t k1 (k1 + k2 ) 2k1
k1 + k2 + (k1 − k2 )e−k1 τ
 
2
+ ln , (3.16)
k1 (k1 − k2 ) 2k1

where
q
k1 = k22 + 2σ 2 ,
k2 = (k − ρησ).
18 Stochastic convenience yield model following a Cox-Ingersoll-Ross process
Chapter 4

Kalman Filter

4.1 Introduction
In 1960 R.E. Kalman published the Kalman Filter (KF). This algorithm makes optimal use of imprecise
data on a (quasi-) linear system with Gaussian errors (white noise) to continuously update the best
estimate of the systems current state. The power of KF is; to compute these updates it is only necessary
to consider the estimates from the previous time step and the new measurement and not all the previous
data. The main idea is that we want to estimate the current state and its uncertainty, but we can not
directly observe these states. Instead we observe noisy measurements.

4.2 Kalman Algorithm


In general the Kalman Filter tries to estimate a state x ∈ <n where xt is given by the stochastic differential
equation

xt = At xt−1 + Bt ut−1 + wt−1 , (4.1)

with a measurement z ∈ <n given by

zt = Ht xt + vt , (4.2)

where

ˆ At is a n × n matrix,

ˆ Bt is a n × l matrix,

ˆ Ht is a m × n matrix,

ˆ wt and vt are the process and measurement noise (resp.) with mean zero and covariance matrices
Q and R (resp.).

Now define

E[xt ] = x̂t , (4.3)


E[(xt − x̂t )(xt − x̂t )0 ] = Pt . (4.4)

The KF algorithm is a predictor-corrector algorithm and uses the time updates for the prediction and
the measurement updates as the corrector. The KF algorithm is given by
20 Kalman Filter

Predictor (Time updates)

x̂−
t = At x̂t−1 + Bt ut−1

Pt− = At Pt−1 A0t + Qt

6
Table 4.1:

?
Corrector (Measurement updates)

Kt = Pk− Ht0 (Ht Pt− Ht0 + Rt )−1

x̂t = x̂− −
t + Kt (zt − Ht x̂t )

Pt = (I − Kt Ht )Pt−

Table 4.2:

In Chapter 5 we discuss the Kalman filter for the CIR process. But first we introduce a simple example
following [6].

4.3 Introductory example

In [6] they use the KF to estimate a random constant. We assume all matrices in Table 4.1 and 4.2 to
be constant. By setting A = 1, B = 0 we obtain x̂− k = x̂k−1 , i.e., we skip the updating step. By setting
H = 1, we get zk = xk +vk , i.e., the measurements comes directly from the state xk . We set Q = 1E −05.
Now we have to choose an intial state to begin with. Since a random variable is normally distributed
with mean zero, we take x0 = 0 to be the intial state. Accordingly we must start with an intial state for
Pk , P0 . It turns out that we can arbitraly choose P0 6= 0 and the filter will eventually converge. Take
P0 = 1, by taking P0 large enough, the choice of x0 does not influence the kalman filter [7]. The crosses
in the following figures are generated by the matlab function

y=-0.37727+normrnd2(0,0.025^2,samples,1);
4.3 Introductory example 21

4.3.1 Simulation results

By randomly choosing R = 0.0238 we get,


0.2

0.1

−0.1

−0.2

−0.3

−0.4

−0.5

−0.6

−0.7

−0.8
0 10 20 30 40 50 60 70 80 90 100

Figure 4.1: Simulation of a random constant, with R = 0.0238. The true value of x = −0.37727 is given
by the green line, the Kalman Filter by the red line and the crosses are the noisy measurements.

Changing the choice of R is made clear by figure 4.2 and 4.3. In figure 4.2 we take R = 1, this will cause
a much slower converging behaviour than in figure 4.1. This is because the filter responds slower to the
noisy measurements. However the filter will eventually converge to the true value of x. In figure 4.3 we
take R = 0.0001, as we can see the filter quickly responds to the measurements and tries to fit it. With
the choice of this R we can expect that it will take very long for the filter to converge to the green line.
0.2

0.1

−0.1

−0.2

−0.3

−0.4

−0.5

−0.6

−0.7

−0.8
0 10 20 30 40 50 60 70 80 90 100
Iteration

Figure 4.2: Simulation of a random constant, with R = 1. The true value of x = −0.37727 is given by
the green line, the Kalman Filter by the red line and the crosses are the noisy measurements.
22 Kalman Filter

0.2

0.1

−0.1

−0.2

−0.3

−0.4

−0.5

−0.6

−0.7

−0.8
0 10 20 30 40 50 60 70 80 90 100

Figure 4.3: Simulation of a random constant, with R = 0.0001. The true value of x = −0.37727 is given
by the green line, the Kalman Filter by the red line and the crosses are the noisy measurements.

4.3.2 How to choose R


Consider for simplicity Q = 0, so (6.2) can be written as zt = Ht xt or It = zt − Ht xt , where It is usually
refered to as the innovations. If we plot It in figure 4.4 we see that the crosses are distributed around
zero. This is expected because RIt is statistically equal to the variance of the error term of vt , R. We
assumed vt is N (0, R). But from the literature [7] it is also known that RIk = Ht Pt− Ht0 + R. We first
choose R randomnly, say R = 0.10. If we plot both the statistically innovations and the theoretical ones
we should have that 68 per cent of the crosses lie inside the theoretical boundary. In figure 4.4 we can
see that only 54 per cent of the crosses lie inside the boundary.
1.5

0.5

−0.5

−1

−1.5
0 10 20 30 40 50 60 70 80 90 100

Figure 4.4: Comparison between the theoretical innovations (blue lines) and the statistical innovations
(red crosses). The number of red crosses between the blue lines is 54 per cent. R = 0.10.

It is therefore necessary to change the value of R, say R = 0.16. We see that 71 per cent of the red
crosses lie between the blue lines. If we now plot the Kalman Filter using this R we see that this is one
of the best choices for R, what we expected.
4.3 Introductory example 23

1.5

0.5

−0.5

−1

−1.5
0 10 20 30 40 50 60 70 80 90 100

Figure 4.5: Comparison between the theoretical innovations (blue lines) and the statistical innovations
(red crosses). The number of red crosses between the blue lines is 71 per cent. R = 0.16.

0.2

0.1

−0.1

−0.2

−0.3

−0.4

−0.5

−0.6

−0.7

−0.8
0 10 20 30 40 50 60 70 80 90 100

Figure 4.6: Simulation of a random constant, with R = 0.16. The true value of x = −0.37727 is given by
the green line, the Kalman Filter by the red line and the crosses are the noisy measurements.
24 Kalman Filter
Chapter 5

The Kalman Filter for the


Ornstein-Uhlenbeck process

To fit the state-space model, the state variables (which in this case are the spot prices and the convenience
yield) are contained inside a state vector. The measurement equation, consisting of this vector and
uncorrelated disturbances to account for possible errors in the data, links actual observations (in this
case the future prices on several different maturities) with latent variables. These latent variables are
assumed to be first-order Markovian processes and are related to systems (2.1) and (2.2). The Kalman
filter will give an optimal prediction for the unobserved data by only considering the previously estimated
value.
Consider again

F (S, δ, τ ) = SeA(τ )−B(τ )δ , (5.1)

where
σ2 σ 1 − e−2kτ 1 − e−kτ
   2
σ2
    
ησρ
A(τ ) = r − α̃ + 2 − τ + + α̃k + σηρ − ,
2k k 4 k3 k k2

and
1 − e−kτ λ
B(τ ) = , α̃ = α − ( ).
k k
In state variable terms, (5.1) can be rewritten in

Ft (τ ) = lnSt + A(τ ) − B(τ )δt , (5.2)

The measurement equation then reads

Yt = dt + Zt [xt , δt ]0 + t , t = 1, .., N OBS, (5.3)

where1

ˆ Yt = [lnFt (τi )], for i = 1, ..., n is a n × 1 vector for n maturities. τi are the maturity dates. Ft (τ )
are observed from market data.

ˆ dt = [A(τi )] for i = 1, .., n is a n × 1 vector.

ˆ Zt = [1, −B(τi )], for i = 1, ..., n is a n × 2 matrix.

ˆ t is a n × 1 vector of uncorrelated disturbances and is assumed to be normal with zero mean and
variance matrix Ht . Ht is a n × n diagonal matrix with hi on its diagonal.
1 NOBS is the number of observations.
26 The Kalman Filter for the Ornstein-Uhlenbeck process

The t in (5.3) term is included to account for possible errors in the measurement. These errors especially
occur when the state variables are unobservable. To get a feeling of the size of the error suppose that the
OU model generates the prices and yields perfectly, and that the state variables can be observed from the
market directly. The included error term in the measurement equation can be seen as the possibilities of
bid-ask spreads, errors in the data etc. The error is assumed to be small in comparison to the variation
of the yield. The matrix Ht is assumed to be diagonal for convenience in order to reduce the number of
parameters to be estimated. The diagonal elements hi are then estimated via the log-likelihood function.

In combination with the relationship xt = lnSt we have

 dxt = (µ − δt − 1 η 2 )dt + ηdWt ,



2 (5.4)
dδt = k(α − δt )dt + σdZt ,

From (5.4) the transition equation follows immediately,

(µ − 12 η 2 )∆t −∆t 0 ξt1


" # " # " #" # " #" #
xt 1 xt−∆t 1
= + + (5.5)
δt kα∆t 0 1 − k∆t δt−∆t 0 1 ξt2

which for simplicity will be written as

αt = ct + Qt αt−∆t + Rξt . (5.6)

where ξt is the transition error. Like t , ξt is also assumed normal with mean zero and has a covariance-
variance matrix given by
" 2 #
σ ∆t ρση∆t
Vt = (5.7)
ρση∆t η 2 ∆t

The matrices, H, Z, Q, c, d given above are parametrized by of the unknown parameter set ϕ =
{k, αλ, η, σ, ρ, µ, hi }. We dropped the time subscript for each matrix because they are time-independent.
Note that Vt does not depend on the state variables {xt , δt }.

5.1 Iterative procedure


The iterative procedure consists of two main parts. Part one is the Kalman Filter which is used to update
the systems matrices. Part two is estimating the parameter set ϕ = {k, αλ, η, σ, ρ, µ, hi }. The algorithm
of the Kalman Filter is given in pseudo code. Define at = E[αt ] and Pt = E[(at − αt )(at − αt )0 ]. The tilde
indicates predicted values.

while ( number of iterations has not been reached , optimal ϕ has not been found ) do
(Kalman Filter)
for i = 1 : N OBS do
(Prediction Equations)
ãti = Q ∗ ati−1 + c;
P̃ti = Q ∗ Pti−1 ∗ Q0 + R ∗ V ∗ R0 ;
ỹti = Z ∗ ãti + D;
(Innovations)
vti = yti − ỹti ;
(Updating equations)
Fti = Z ∗ P̃ti ∗ Z 0 + H;
ati = ãti + P̃ti ∗ Z 0 ∗ Ft−1
i
∗ vti ;
0 −1
Pti = P̃ti − P̃ti ∗ Z ∗ Fti ∗ Z ∗ P̃ti ;
dFti = det Fti ;
if dFti 6 0 then
5.2 Numerical results for the Ornstein-Uhlenbeck process 27

dF t = 10−10 ;
end if
(Log-likelihood function per iteration)
logl(i) = −(n/2) ∗ ln(2 ∗ π) − 0.5 ∗ ln(dFti ) − 0.5 ∗ vt0 i ∗ Ft−1
i
∗ vti ;
end for P
LogL = i logl(i);
(Adjustment for ϕ via a Matlab optimization routine)
end while
Via an optimalisation routine, the vector ϕ is chosen such that the total sum of the log-likelihood function
is maximized and the innovations minimized. After this is done, the matrices in the measurement and
transition equation are updated and the Kalman Filter algorithm will then be repeated. This iterative
procedure is repeated untill the optimized ϕ is found. With this optimized set of parameters the matrices
will be updated once more and are used for the last time to generate the paths of the non-observable
variables via the Kalman Filter. The total sum of the log-likelihood function is calculated as follows
1 1X 1 X 0 −1
lnL(Y ; ϕ) = − nln2π − ln|Ft | − v F vt , (5.8)
2 2 t 2 t t t

where Yt is the information vector at time t and it is assumed that Yt conditional on Yt−dt is normal with
mean E[Yt |Yt−dt ] and covariance matrix Ft .2

5.2 Numerical results for the Ornstein-Uhlenbeck process


We use weekly observation (on every friday to account for possible weekend effects) of light crude oil
data from 01-02-2002 until 25-01-2008 (313 observations). At each observation seven monthly contracts
(F1,F2,F3,F4,F5,F6,F7) (n = 7) are observed. Each diagonal element of the error matrix H corresponds
to each maturity, i.e. h1 corresponds to F1, h2 corresponds to F2 and so on. The used marketdata is
such that the time to maturities (τi ) are constant for each forward contract i and for each observation
data, i.e. for each observation date of contract i there exists a future price with maturity Ti .

5.2.1 Setting up the calibration


In order to start the iterative process, some difficulties must be overwon. Namely, the initial choice of
the parameterset ϕ and the non-observable variables at time zero,
 i.e. x0 and δ0 .
0.3, 0.2, 0.06, 0.01, 0.4, 0.4, 0.8, Var[(lnF1)]2 ,
We start with ϕ = {k, µ, α, λ, η, σ, ρ, h1 , h2 , h3 , h4 , h5 , h6 , h7 } =

2 2 2 2 2 2
Var[(lnF2)] , Var[(lnF3)] , Var[(lnF4)] , Var[(lnF5)] , Var[(lnF6)] , Var[(lnF7)] . The first seven param-
eters are chosen arbitrarily. However, for the diagonal elements hi of the error variance matrix H we
choose the squares of the measurement variance. Therefore we expect the error to be small in comparison
to the variance of the measurements. For the non-observable parameters (cf. [8]), the nearest future price
is retained as the spot price S and
ln(Ft (τ1 )) − ln(Ft (τ2 ))
δtimplied = r − . (5.9)
τ1 − τ2

with δ0 = δ0implied .

5.2.2 Results
The optimized parameter set is estimated for different initial sets and given in Table 5.1. To test the
robustness of the calibration, we first choose randomly an initial parameter set. This gaves us the
optimized set, which we then inserted as the initial one. Within a few interation steps the parameters
converges to the same values.
Remark: In the following sections we use the second column of Table 5.1 to be the initial parameter set.
2 This Ft is not the same as the future price
28 The Kalman Filter for the Ornstein-Uhlenbeck process

Parameters Ini parset Opti parset Ini parset Opti parset Ini parset Opti parset
k 0.3 1.4221 (0.0372) 0.3 1.4221 (0.0380) 2 1.4221 (0.0382)
µ 0.2 0.3733 (0.1471) 0.2 0.3733 (0.1376) 0.2 0.3733 (0.1382)
α 0.06 0.0699 (0.1128) 0.2 0.0699 (0.1025) 0.06 0.0699 (0.1082)
λ 0.01 -0.0183(0.1602) 0.1 -0.0183(0.1459) 0.01 -0.0183(0.1543)
η 0.4 0.3630 (0.0137) 0.4 0.3630 (0.0139) 0.5 0.3630 (0.0153)
σ 0.4 0.4028 (0.0165) 0.4 0.4028 (0.0172) 0.4 0.4028 (0.0181)
ρ 0.8 0.8378 (0.0162) 0.5 0.8378 (0.0164) 0.5 0.8378 (0.0177)
|h1 | 0.0246 0.0188 (0.0008) 0.0246 0.0188 (0.0007) 0.01 0.0188 (0.0007)
|h2 | 0.0268 0.0072 (0.0003) 0.0268 0.0072 (0.0003) 0.01 0.0072 (0.0003)
|h3 | 0.0291 0.0022 (0.0001) 0.0291 0.0022 (0.0001) 0.01 0.0022 (0.0001)
|h4 | 0.0313 0.0000 (0.0001) 0.0313 0.0000 (0.0001) 0.01 0.0000 (0.0001)
|h5 | 0.0336 0.0006 (0.0000) 0.0336 0.0006 (0.0000) 0.01 0.0006 (0.0000)
|h6 | 0.0357 0.0000 (0.0001) 0.0357 0.0000 (0.0001) 0.01 0.0000 (0.0001)
|h7 | 0.0377 0.0014 (0.0001) 0.0377 0.0014 (0.0001) 0.01 0.0014 (0.0001)
Log-Likelihood 8744.6479 8744.6479 8744.6479

Table 5.1: Optimized parameterset (Opti parset) for different initial parametersets (Ini parset). Standard
errors in parentheses.

5.2.3 Results for different number of contracts


In this section we test the method for different number of contracts. We see that the standard error
increases if only two contracts are used. This is expected because the Kalman Filter now has to estimate
two unobservable values using by only two datasets.

Contracts F1,F2,F3,F4,F5,F6,F7 F1,F3,F5,F7 F1,F7


k 1.4221 (0.0372) 1.4591 (0.0602) 1.7628 (0.4897)
µ 0.3733 (0.1471) 0.3654 (0.1354) 0.8134 (0.5488)
α 0.0699 (0.1128) 0.0653 (0.1004) 0.5169 (0.5381)
λ -0.0183(0.1602) -0.0331(0.1475) 1.8517 (2.2353)
η 0.3630 (0.0137) 0.3610 (0.0139) 0.3501 (0.0153)
σ 0.4028 (0.0165) 0.3995 (0.0183) 0.4108 (0.0705)
ρ 0.8378 (0.0162) 0.8418 (0.0174) 0.8172 (0.0234)
|h1 | 0.0188 (0.0008) 0.0161 (0.0007) 0.0188 (0.0012)
|h2 | 0.0072 (0.0003) 0.0000 (0.0003) 0.0081 (0.0031)
|h3 | 0.0022 (0.0001) 0.0021 (0.0001)
|h4 | 0.0000 (0.0001) 0.0010 (0.0012)
|h5 | 0.0006 (0.0000)
|h6 | 0.0000 (0.0001)
|h7 | 0.0014 (0.0001)
Log-Likelihood 8744.6479 4001.8997 1440.5857

Table 5.2: Optimized parameterset (Opti parset) for different initial parametersets (Ini parset). Standard
errors in parentheses.

5.2.4 Estimated future prices versus observered future prices


We plot the state variable xt (the log of the spot price) versus the one-month maturity of the log of the
future prices, i.e. ln(Ft (τi )). The two curves are following each other quite good but are not identical to
each other.
5.2 Numerical results for the Ornstein-Uhlenbeck process 29

4.6

4.4

4.2

3.8

3.6

3.4

3.2

3
0 50 100 150 200 250 300 350

Figure 5.1: Blue line: State variable xt , Red line:ln(Ft (τ1 )).

5.2.5 Filtered convenience yield versus implied convenience yield


Nowadays traders imply the convenience yield via the future prices like in (5.9). The estimated conve-
nience yield is plotted versus the implied convenience yield.
1

0.8

0.6

0.4

0.2

−0.2

−0.4

−0.6

−0.8
0 50 100 150 200 250 300 350

Figure 5.2: Blue line:Filtered δt , Red line:δtimplied .


30 The Kalman Filter for the Ornstein-Uhlenbeck process

5.2.6 Innovations vt
For each future contract we plot the innovation, i.e. vti = yti − ỹti . We assumed the measurement errors,
t in equation (5.3) to be normal with mean zero and variance H. Considering the figures, this assumption
is acceptable. Note that there are some transcend points. This could be caused by data errors.

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0

−0.1 −0.1

−0.2 −0.2

−0.3 −0.3

−0.4 −0.4
0 50 100 150 200 250 300 350 0 50 100 150 200 250 300 350

Figure 5.3: Innovation corresponding to F1. Figure 5.4: Innovation corresponding to F2.
Mean = -8.1734e-004, Variance = 0.0022. Mean = 8.6078e-004, Variance = 0.0019.

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0

−0.1 −0.1

−0.2 −0.2

−0.3 −0.3

−0.4 −0.4
0 50 100 150 200 250 300 350 0 50 100 150 200 250 300 350

Figure 5.5: Innovation corresponding to F3. Figure 5.6: Innovation corresponding to F4.
Mean = 6.4612e-004, Variance = 0.0017. Mean = -1.0181e-004, Variance = 0.0015.

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0

−0.1 −0.1

−0.2 −0.2

−0.3 −0.3

−0.4 −0.4
0 50 100 150 200 250 300 350 0 50 100 150 200 250 300 350

Figure 5.7: Innovation corresponding to F5. Figure 5.8: Innovation corresponding to F6.
Mean = -5.5711e-004, Variance = 0.0014. Mean = -3.4456e-004, Variance = 0.0013.
5.2 Numerical results for the Ornstein-Uhlenbeck process 31

0.4

0.3

0.2

0.1

−0.1

−0.2

−0.3

−0.4
0 50 100 150 200 250 300 350

Figure 5.9: Innovation corresponding to F7. Mean = 6.1501e-004, Variance = 0.0012.

5.2.7 Parameter explanation


If we look at Table 5.1, we see an mean-reverting term, α of 0.0699. In figure 5.2 we can see that the
convenience yield indeed reverts to this mean. The correlation between the two state variables is 0.8378.
To find graphical evidence for this high number we made a scatterplot of the increments of both the
state-variables, i.e. ∆xt := xt − xt−∆t versus ∆δt := δt − δt−∆t .

0.2

0.15

0.1
Increments of the state variable delta

0.05

−0.05

−0.1

−0.15

−0.2

−0.25

−0.3
−0.3 −0.25 −0.2 −0.15 −0.1 −0.05 0 0.05 0.1 0.15
Increments of the state variable x

Figure 5.10: Scatterplot of (∆xt , ∆δt ) for 313 observations.

Since the pattern of dots slopes from lower left to upper right, it suggests a positive correlation between
the variables being studied, which is exactly what we expected.

5.2.8 Implementation issues


There are a few important implementation details worth mentioning. The log-likelihood function esti-
mates the optimal parameterset. For that, it has control of a parameter set bound. We use the following
bounds

%[ mu sigmaS alpha k sigmaC rho lambda h1 h2 h3 h4 h5 h6 h7]:


lowerbound=[ -10 0.001 -10 0.001 0.001 0 -10 -1 -1 -1 -1 -1 -1 -1];
upperbound=[ 10 10 10 10 10 1 10 1 1 1 1 1 1 1];

If this is not done, the iterative procedure may break down. In case of matrix H, consisting of the
variances of the error terms, can become negative. But being negative, this can cause problems in the
KF. In (??) Ft could converge to a negative diagonal matrix, becoming impossible to inverse. So we
square each element of H before calculating Ft . If the parameters hi come out negative, it is ok, because
they effectively enter Ft as the variance, i.e. they will be squared. This is why hi in Table 5.1 and in
Table 5.2 are in absolute value.
32 The Kalman Filter for the Ornstein-Uhlenbeck process

5.2.9 Kalman Forecasting


We test a Kalman forecasting method on half of the observations. The first half, from observation i=1
until i=156 we perform the KF algorithm with the optimized parameter set given in the third column of
Table 5.1. From i=157 until i=313 we forecast the state variables, xt and δt by the following recursive
equations

at = Qt at + ct ,
Pt = Qt Pt Q0t + Rt Vt Rt0 ,
yt = Zt at + Dt . (5.10)

Forecasting for the state variable δt is not a succes. This can be explained by the sudden drop at 160.
4.6

4.4

4.2

3.8

3.6

3.4

3.2

3
0 50 100 150 200 250 300 350

Figure 5.11: Forecast over half a sample of the log of the future prices (F1-F7).

−1
0 50 100 150 200 250 300 350

Figure 5.12: Forecast over half a sample of the state variables. Blue line: xt , green line: δt , red lines:
forecasting

The Kalman forecasting can not absorb this sudden drop in the convenience yield. For that, it follows
the previous estimations. However, as noted earlier, the mean-reverting term is equal to 0.0699, which
is approximately equal to the forecasting. Also for xt , the sudden drop at 250 can not be absorbed by
this forecasting method. This is a real disadvantage of this method. A way to get the method to absorb
these drops, jumps can be inserted in the stochastic processes of both the state variables.
Chapter 6

The Kalman Filter model for the


Cox-Ingersoll-Ross process.

In state variable terms, (3.7) can be written in

Ft (τ ) = lnSt + A(τ ) − B(τ )δt , (6.1)

where A(τ ) and B(τ ) are given in (3.14) and (3.13). The measurement equation then reads

Yt = dt + Zt [xt , δt ]0 + t , t = 1, .., N OBS, (6.2)

where

ˆ Yt = [lnF (τi )], for i = 1, ..., n is a n × 1 vector for n maturities. τi are the maturity dates.
ˆ dt = [A(τi )] for i = 1, .., n is a n × 1 vector.
ˆ Zt = [1, −B(ti )], for i = 1, ..., n is a n × 2 matrix.
ˆ t is a n × 1 vector of uncorrelated disturbances and is assumed to be normal with zero mean and
variance matrix Ht .

Another motivation for including the error term is that perhaps the dynamics of the stochastic convenience
yield does not include a square-root. If so, the yields implied by the CIR model will differ from the
observed yields. Furthermore, since the CIR model forbids negativity of the convenience yield there are
two solutions; firstly we can replace any negative element of the estimate δt with zero. Secondly, we
could just skip the updating step, i.e. we set δt = δt−1 whenever δt is negative. The reason why this is
done is just a matter of convenience and it seems rather difficult to impose the positivity constraint in
the estimation procedure and thus a solution like these is needed.
Again, the vector [xt , δt ]0 is the data which we want to estimate. From (3.1) and (3.5) the transition
equation immediately follows
1 −(1 + 12 η 2 )∆t
         1 
xt µ∆t xt−∆t 1 0 ξt
= + + .
δt kα∆t 0 1 − k∆t δt−∆t 0 1 ξt2

For notational simplicity we write

αt = ct + Qt αt−1 + Rt ξt , t = 1, ..N OBS, (6.3)

where E[ξti ] = 0 for i = 1, 2 and where the covariance matrix of ξti , Vt , is given by

E[(xt − E[xt ])2 |xt−∆t ]


 
E[(xt − E[xt ])(δt − E[δt ])|xt−∆t , δt−∆t ]
Vt =
E[(xt − E[xt ])(δt − E[δt ])|xt−∆t , δt−∆t ] E[(δt − E[δt ])2 |δt−∆t ]
 p p 
Var[xt |x
pt−∆t ] Var[xt |xt−∆t ] Var[δt |δt−∆t ]
= p
Var[xt |xt−∆t ] Var[δt |δt−∆t ] Var[δt |δt−∆t ]
34 The Kalman Filter model for the Cox-Ingersoll-Ross process.

 2
√ p p 
√ p η ∆tδp
t−∆t ρη ∆t δt−∆t Var[δt |δt−∆t ]
= .
ρη ∆t δt−∆t Var[δt |δt−∆t ] Var[δt |δt−∆t ]
The difference between Vt for the OU process and the CIR process is the time dependency. Implementing
the Kalman Filter for the CIR process includes feedback from the kalman filter to update Vt with δt|t−1 .
As mentioned earlier, since the square root is taking of the convenience yield, we replace any negative
element of the estimate δt|t−1 with zero.
General remark: it would be better to use δt + γ, γ a constant parameter.
Chapter 7

Conclusion

We implemented the KF for the OU process. Both the CY as well as the state-variable x (log of the
spot prices) seems to follow the implied yield and the market prices (resp.) quite good. Also, different
initial values for the parameterset will eventually converge to the optimized set with the same value of
the log-likelihood. This is a good result and tests the robustness of the method.
The main difference bewteen the systmes matrices of both processes is the transition error covariance-
variance matrix Vt . For the CIR process, we simply replaced any negative element of the CY by zero,
but since it is negative for a large number of observations, this will probably give rise to large standard
errors in the optimized parameterset ϕ.

7.1 Further research


Finish the implementation of the Kalman Filter for the CIR process and compare the results with the
OU process. If the CY in the CIR gives problems because it can not be negative we could insert a jump-
constant in the CY. Perhaps it is possible to extend the two factor stochastic process by a third factor,
e.g. stochastic volatility. The problem with this is that the solution of the future prices is assumed to have
an affine form solution. This makes the Kalman Filter considerable easier. Including stochastic volatility
could mess this up. Another idea is to price options on commodities using the optimized parameterset.
36 Conclusion
Bibliography

[1] F.H.C. Naber, Fast solver for the three-factor Heston-Hull-White problem, 2006-2007, Wholesale
Banking Amsterdam ING.
[2] A. Krul, L∞ Error estimates for the solution of the Black-Scholes and Hull-White models on truncated
domains with a payoff boundary condition, 2007, Wholesale Banking Amsterdam ING.
[3] P. Bjerksund, Contingent Claims Evaluation when the Convenience Yield is stochastic: Analytical
Results, 1991.
[4] D.R. Ribeiro and S. D. Hodges, A Two-Factor Model for Commodity Prices and Futures Valuation,
2004.
[5] R. Gibson and E. S. Schwartz, Stochastic Convenience Yield and the Pricing of Oil Contingent Claims,
The Journal of Finance, Volume 45, Issue 3(Jul.1990), 959-976.
[6] G. Welch and G. Bishop, An Introduction to the Kalman Filter, July 24, 2006.
[7] A. Heemink , http://ta.twi.tudelft.nl/wagm/users/heemink/ch5dataas.doc, Delft University of Tech-
nology.
[8] D. Lautier, The Kalman Filter In Finance: An Application to Term Structure Models of Commodity
Prices and a Comparison between the Simple and the Extended Filters, 06/12/02, working paper.

[9] D. Lautier, The Informational Value of Crude Oil Futures Prices, June 2003.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy