KalmanSlides 2
KalmanSlides 2
Samuel N. Cohen
Mathematical Institute
University of Oxford
Filtering: Introduction 2
A basic problem
Bayesian estimation of the mean
tσ 2 µ0 + τ02 Ȳt 1
µt = , τt2 =
tσ 2 + τ02 1/τ02 + t/σ 2
1 Pt
with Ȳt = t s=1 Ys .
I This simplification is special to this particular setting.
Example 1
I Equivalently,
X0 X1 X2 ··· XT
Y1 Y2 ··· YT
µ0 /τ 2 + Y1 /σ 2 1
1|0 2
X1 |Y1 ∼ N 2 + 1/σ 2 , 2 + 1/σ 2 =: N(µ1|1 , τ1|1 ).
1/τ1|0 1/τ1|0
where
2 2
µt|t−1 = µt−1|t−1 , τt|t−1 = τt−1|t−1 + γ2,
2
µt−1|t−1 /τt|t−1 + Yt /σ 2 2 1
µt|t = , τt|t = 2
.
1/τ 2 + 1/σ 2 1/τt|t−1 + 1/σ 2
t|t−1
2 )
(µ1|0 , τ1|0 2 )
(µ2|1 , τ2|1 ···
2 )
(µ0|0 , τ0|0 2 )
(µ1|1 , τ1|1 2 )
(µ2|2 , τ2|2
Y1 Y2
Example 2
Xt = AXt−1 + Wt , Yt = CXt + Vt
Furthermore
E [Y |Z ] = E [Y ] + cov(Y , Z )var(Z )−1 (Z − E [Z ])
var(Y |Z ) = var(Y ) − cov(Y , Z )var(Z )−1 cov(Y , Z )>
µt|t = µt|t−1 + Kt ηt ,
Pt|t = (I − Kt C )Pt|t−1 .
Example 3
PN−1,N|N = (I − KN C )APN−1|N−1 ,
> >
Pt−1,t|N = Pt|t Jt−1 + Jt (Pt,t+1|N − APt|t )Jt−1 .
We can write
xt φ 1 xt−1 1 φ 1
Xt = = + zt = Xt−1 + Wt
θzt 0 0 θzt−1 θ 0 0
and
Yt = xt = 1 0 Xt−1 .
I Hence we can apply the Kalman filter to X , and so efficiently
calculate
1 0 µt|t−1 = 1 0 E [Xt |Yt−1 ] = E [xt |xt−1 , xt−2 , ...].
Example 4
Filtering: Discrete Time: Hidden Markov Models 29
Continuous time
Much more technically difficult
Theorem
Suppose we have a probability measure Q ∼ P. Write the
Radon–Nikodym density Z = dQ/dP, and suppose we have a
filtration {Ft }t≥0 . Then for any t ≥ 0 and any random variable ξ,
we know that
EP [Z ξ|Ft ]
EQ [ξ|Ft ] = .
EP [Z |Ft ]
∂φ 1 ∂2φ
Lφ = f (t, x) + · 2 κ(t, x)2 .
∂x 2 ∂x
I We expect L to be part of the solution to our filtering
problem.
I We define a probability Q by dQ
dP = ZT , where
Z Z t 1 t
Z
Zt = E − c(s, Xs )dWs = exp − c(s, Xs )dWs − c(s, Xs )2 dt .
t 0 2 0
∂φ 1 ∂2φ
d(Λφ(X ))t = Λt dXt + Λt 2 κ(t, Xt )2 dt + Λt φ(Xt )c(t, Xt )dYt
∂x 2 ∂x
∂φ
= Λt Lφ(Xt )dt + Λt κ(t, Xt )dBt + Λt φ(Xt )c(t, Xt )dYt
∂x
I Let’s assume
R X has a smooth density given Yt , so
σt (φ) = R φ(x)q(t, x)dx. Then we see that
Z Z Z tZ
φ(x)q(t, x)dx = φ(x)q(0, x)dx + Lφ(x)q(s, x)dxds
R R 0 R
Z tZ
+ φ(x)c(s, x)q(s, x)dx dYs
0 R
I By integration by parts, if L∗ is the adjoint of L
∂(qf ) 1 ∂ 2 (qκ)
L∗ q = + · ,
∂x 2 ∂x 2
we calculate
Z Z Z t Z t
φ(x)q(t, x)dx = φ(x) q(0, x)+ L∗ q(s, x)ds+ c(s, x)q(s, x)dYs dx
R R 0 0
q(t, x)
p(t, x) = R 0 0
.
R q(t, x )dx
I One can also get a nonlinear SPDE for the normalized density.
I Solving SPDEs is hard, so this equation is not frequently
solved in practice in this general form – instead it suggests
good approximations, or allows special cases to be derived.
is deterministic.
I Also, E [(Xt − X̂t )3 |Yt ] = 0.
I Taking φ(x) = x 2 ,
Z
2 2
πt (X ) = π0 (X ) + (2aπs (X 2 ) + b 2 )du
[0,t]
Z
+c (πs (X 3 ) − X̂u πu (X 2 ))dV .
[0,t]
Z t Z t
X̂t2 = X̂02 + 2
2a(X̂s ) ds + 2c X̂s Ps dVs .
0 0
Filtering: Calibration 47
Calibrating a filter
A setup
Filtering: Calibration 48
Calibrating a filter
The equations
Filtering: Calibration 49
Calibrating a filter
The EM algorithm
Filtering: Calibration 50
Calibrating a filter
The maximum estimates
1 X 1 X
â = µt|N − b̂ µt−1|N
N N
1 h X i
ĉ = E (Xt − â − b̂Xt−1 )2 YN
N
1 X
= Pt|N + µ2t|N + â2 − 2âµt|N + 2âb̂µt−1|N
N
+ b̂ 2 (Pt−1|N + µ2t−1|N ) − 2b̂Pt−1,t|N − 2b̂µt|N µt−1|N )
1 X
fˆ = (Yt − µt|N )2 + Pt|N
N
Filtering: Calibration 51
The Kalman–Bucy filter
Simplifying...
Example 6
Filtering: Calibration 52
Pairs trading
A simple application
Filtering: Conclusion 57