• No se han encontrado resultados

3.8. ANÁLISIS E INTERPRETACIÓN DE RESULTADOS

3.8.3. Observación

In real-world scenarios where the usage of models is afflicted by noisy or irregular data, smoothing or fil- tering techniques often prove useful in attaining estimates of the unknown variables (state space models where the latent variable is unknown, thus termed hidden Markov models). Such a method was developed by Kalman (1960).

Suppose that the variable under consideration to be modelled, xk, depends on its previous state, xk−1,

perturbed by some noise factor,wk, and satisfies

xk=Akxk−1+Bkuk+wk. (A.69)

Ak is the state transition model from statek−1 to statek,Bk is the control input model,uk is the control

input vector andwkN(0, Qk) is the noise of the process, with Qk =E[wkwkT]. Control inputs are often

not relevant in financial models and are mostly omitted in the pertaining literature, as will be done here as well. (A.69) represents the state transition equation.

The measurement equation, which relatesxk to the current observation, is given by

zk =Hkxk+vk, (A.70)

A.2 Statistical Models, Tests and Distributions 139

A.2.12.1 Derivation of the Kalman Filter Algorithm

This section is based on content taken from Mastro (2013).

The Kalman filter algorithm utilises (A.69) and (A.70) to find the optimal weighting, called the Kalman gain, between the model predicted estimate and the observed value by finding the minimum variance of the mean square error between the true state, xk, and the estimated state, ˆxk. The error at time kis given by

ek=xkxˆk. (A.71)

The prediction estimate for the state at time stepk, denoted by ˆxk, is obtained using the transition model

at (A.69) as follows:

ˆ

xk =Akxˆk1. (A.72)

Similarly, the observation model at (A.70) is used with the predicted estimate to determine the observed (measurement) estimate for the state at time stepk:

ˆ

zk =Hkxˆ−k =HkAkxˆk1. (A.73)

The innovation or measurement residual, ik, is the difference between the actual observation at timek,zk,

and the predicted observation at (A.73):

ik=zkzˆk−=zkHkxˆ−k.

The corrected estimate for the state variable atk, ˆxk, is calculated by adding to the transition estimate the

innovation residual, weighted by the Kalman gain Kk:

ˆ

xk= ˆxk +Kkik

= ˆxk +Kk(zkHkxˆ−k)

xˆk= ˆxk(IKkHk) +Kkzk. (A.74)

Substituting (A.70) into (A.74) yields ˆ

xk= ˆxk(IKkHk) +Kk(Hkxk+vk). (A.75)

Now the error covariance matrix is given by

Pk=E[ekeTk] =E[(xkxˆk)(xkxˆk)T]. (A.76)

Using the expression at (A.75) in (A.76) gives

Pk=E[(xkxˆ−k(IKkHk) +Kk(Hkxk+vk)])(xkxˆ−k(IKkHk) +Kk(Hkxk+vk))T]

=E[((IKkHk)(xkxˆ−k)−Kkvk)((IKkHk)(xkxˆ−k)−Kkvk)T].

(A.77) The error betweenxk and ˆxk, written as

A.2 Statistical Models, Tests and Distributions 140

is uncorrelated with the measurement noisevk, thus (A.77) becomes

Pk= (IKkHk)E[(xkxˆ−k)(xkxˆk−)T](IKkHk)T +KkE[vkvTk]KkT

= (IKkHk)Pk−(IKkHk)T +KkRkKkT.

(A.79) The mean square errors are the diagonal elements of the error covariance matrix at (A.79), which are simply the variances (since the diagonal elements of a covariance matrix are the variances). The total mean square error is the sum of the diagonal mean square error terms. The sum of the diagonal elements of a square matrix is called the trace. Hence to find the minimum mean square error and obtain an expression for the optimal Kalman gain, the minimum of the trace needs to be determined.

First, expanding out the terms in (A.79) gives

Pk=Pk−−KkHkPk−−PkKkTHkT +Kk(HkPkHKT +Rk)KkT. (A.80)

Now the trace ofPk, denoted by Tr(Pk), is given by

Tr(Pk) = Tr(Pk−)−Tr(KkHkPk−)−Tr(Pk K T kHkT) + Tr(Kk(HkPkH T K+Rk)KkT) = Tr(Pk−)−2 Tr(KkHkPk−) + Tr(Kk(HkPkHKT +Rk)KkT), (A.81) where the second line follows since

Tr(KkHkPk−) = Tr(P

k K

T kHkT).

To find the optimalKk, (A.81) is differentiated with respect to Kk and set to zero:

dTr(Pk) dKk = −2(HkPk−) T + 2K k(HkPkH T K+Rk) = 0.

Solving for Kk yields the optimal Kalman gain as

Kk=PkH

T

k(HkPkH T

K+Rk)−1. (A.82)

The measurement prediction covariance,Sk, is defined as

Sk :=HkPkHkT +Rk. (A.83)

Thus the Kalman gain can be rewritten as

Kk=PkHkT(Sk)−1. (A.84)

Multiplying both sides of (A.84) by SkKkT yields

KkSkKkT =P

k H

T

A.2 Statistical Models, Tests and Distributions 141

Using (A.83) and then (A.85) in (A.80) results in the correction expression for the error covariance:

Pk =Pk−−KkHkPk−−Pk KkTHkT +KkSkKkT =Pk−−KkHkPk−−Pk K T kHkT +Pk H T kKkT =Pk−−KkHkPk− ⇒Pk = (IKkHk)Pk. (A.86)

The correction step of the Kalman filter is fully defined by (A.82), (A.74) and (A.86). The expression for the prediction of the state variable for the next time step is (A.72), with the corresponding error estimate given by (A.78). The remaining component to determine is the prediction of the error covariance.

Substituting (A.69) and (A.72) into (A.78) gives

ek = (Akxk1+wk)−Akxˆk1

=Akek1+wk.

The prediction of the error covariance for the next time step is

Pk−=E[(ek)(e

k)T] =E[(Akek1+wk)(Akek1+wk)T]. (A.87)

wk and ek1 are uncorrelated, as wk only occurs between times k−1 and k, whilst ek1 accumulates up

until time k−1 only. Thus the expression for the prediction of the error covariance is

Pk− =AkE[(ek)(ek) T]AT k +E[wkWkT] ⇒Pk− =AkPk−1ATk +Qk. (A.88)

Documento similar