0% found this document useful (0 votes)
15 views

Part 5

Time Series
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)
15 views

Part 5

Time Series
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/ 31

MATH11131 Part 5: State Space models

⊲ MATH11131
models
Part 5: State Space

State space models

Ioannis Papastathopoulos
School of Mathematics, University of Edinburgh

1 / 31
MATH11131 Part 5: State Space
models

⊲ State space models


Introduction
Basic Idea I
Basic Idea II
Multivariate normal distribution
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
Kalman filter
Kalman filter
Nile data
State space models
Nile data
Forecast errors
Implications of (2)
State error recursion
State smoothing I
State smoothing II
Kalman filter and smoother
State smoothing III
Nile data
Missing values
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

2 / 31
Introduction

MATH11131 Part 5: State Space


models  State space models, also called structural models, provide a very general approach
State space models
⊲ Introduction to time series modelling
Basic Idea I
Basic Idea II
Multivariate normal distribution  They originated in the 1960s in the control theory/electrical engineering literature, then
A useful lemma
Local trend model were taken up for economic modelling, and are now used in many application areas.
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
 They allow maximum likelihood estimation for the model parameters and easy
Kalman filter
Kalman filter
treatment of missing data
Nile data
Nile data
Forecast errors  The basic model presupposes that the observed data follow a normal linear model that
Implications of (2)
State error recursion depends upon an unobservable underlying state, so the whole theory hinges upon
State smoothing I
State smoothing II computations for the multivariate normal distribution.
Kalman filter and smoother
State smoothing III
Nile data
Missing values
 The theory extends to much wider classes of models, often using Monte Carlo methods
Nile data
Initialisation
known as particle filters, which are a very active topic of research, with applications in
General state space model
ARMA model
finance, genetics, atmospheric science, etc.
Comparison with ARIMA models
Summary

3 / 31
Basic Idea I

MATH11131 Part 5: State Space


models  An unseen state process {µt } follows a Markov model, so the distribution of µt+1
State space models
Introduction
depends only on µt .
⊲ Basic Idea I
Basic Idea II
Multivariate normal distribution  The observed process Yt is such that Yt depends only on µt . Hence we have
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing State equation : µt ∼ K(µt | µt−1 )
Notation and basic identities
Kalman filter Observation equation : yt ∼ g(yt | µt )
Kalman filter
Kalman filter
Nile data
Nile data where the kernel K determines the evolution of {µt } and g determines the observation
Forecast errors
Implications of (2)
process in terms of µt . In general K and g might vary with time t.
State error recursion
State smoothing I
State smoothing II
Kalman filter and smoother
 We can write this as:
State smoothing III
Nile data
Missing values
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

4 / 31
Basic Idea II

MATH11131 Part 5: State Space


models  Let πs|t denote the conditional density of the underlying state µs given observations
State space models
Introduction
Y1 , . . . , Yt .
Basic Idea I
⊲ Basic Idea II  Just after time t − 1, we have observed Y1 , . . . , Yt−1 , and our information about the
Multivariate normal distribution
A useful lemma unobserved state of the system is summarised in πt−1|t−1 . At that point our density for
Local trend model
Local trend model µt is given by Z
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
πt|t−1 (µt ) = K(µt | µt−1 ) πt−1|t−1 (µt−1 )dµt−1 .
Kalman filter
Kalman filter
Nile data  At time t we observe Yt , and then can update πt|t−1 to
Nile data
Forecast errors
Implications of (2)
πt|t−1 (µt ) g(yt | µt )
State error recursion
State smoothing I πt|t (µt ) = R ·
State smoothing II πt|t−1 (µt ) g(yt | µt )dµt
Kalman filter and smoother
State smoothing III
Nile data
Missing values
 We repeat these prediction and filtering (or data assimilation) steps each time a
Nile data
Initialisation
new observation arrives.
General state space model
ARMA model  The steps can be performed explicitly in very few cases, so usually numerical
Comparison with ARIMA models
Summary approximations are needed.
 The normal model is an exception, since in that case both steps can be performed
analytically.

5 / 31
Multivariate normal distribution

MATH11131 Part 5: State Space


models Definition 1. An n-dimensional multivariate normal random variable
State space models
Introduction
X = (X1 , . . . , Xn )T with mean µn×1 and covariance matrix Σn×n has density
Basic Idea I
Basic Idea II
 
⊲ Multivariate normal distribution 1 1 T −1 n
A useful lemma f (x; µ, Σ) = n/2
exp − (x − µ) Σ (x − µ) , x, µ ∈ R ;
Local trend model
Local trend model
(2π) |Σ| 1/2 2
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
we write X ∼ Nn (µ, Σ). We assume that the distribution is not degenerate, in which case
Kalman filter
Kalman filter
Σ is positive definite, then its determinant |Σ|> 0.
Nile data

Lemma 1. If X ∼ Nn (µ, Σ), Y1T = (X1 , . . . , Xq ) and Y2T = (Xq+1 , . . . , Xn ), and we write
Nile data
Forecast errors
Implications of (2)
State error recursion      
State smoothing I
Y1 µ1 Σ11 Σ12
State smoothing II
X= ∼ Nn ,
Kalman filter and smoother
State smoothing III
Y2 µ2 Σ21 Σ22
Nile data
Missing values
Nile data then
Initialisation
General state space model
ARMA model
 the marginal distribution of Y1 is Nq (µ1 , Σ11 )
Comparison with ARIMA models
Summary
 the conditional distribution of Y1 given Y2 = y2 is

Nq (µ1 + Σ12 Σ−1


22 (y2 − µ 2 ), Σ11 − Σ −1
12 22 Σ21 )
Σ

6 / 31
A useful lemma

MATH11131 Part 5: State Space


models Lemma 2. Let Xn×1 , Ym×1 and Zp×1 have a joint multivariate normal distribution and
State space models
Introduction
suppose that their respective variance matrices ΣXX , ΣY Y , ΣZZ are nonsingular and that
Basic Idea I
Basic Idea II
cov(Y, Z) = ΣY Z = 0. Then in an obvious notation, we have
(a) E(X | Y = y) = µX + ΣXY Σ−1
Multivariate normal distribution
⊲ A useful lemma
Local trend model
Y Y (y − µY ),
Local trend model
Filtering, prediction and smoothing (b) var(X | Y = y) = ΣXX − ΣXY Σ−1
Y Y ΣY X ,
Notation and basic identities
Kalman filter
Kalman filter
(c) E(X | Y = y, Z = z) = E(X | Y = y) + ΣXZ Σ−1
ZZ (z − µz )
Kalman filter
Nile data
Nile data
(d) var(X | Y = y, Z = z) = var(X | Y = y) − ΣXZ Σ−1
ZZ ΣZX
Forecast errors
Implications of (2)
State error recursion  Essentially all the subsequent treatment depends on this lemma:
State smoothing I
State smoothing II
Kalman filter and smoother
– given data up to time t, we predict the data at time t + 1 using the conditional
State smoothing III
Nile data
mean of Yt+1 given Y1 , . . . , Yt ;
Missing values – if Ys is missing, we replace it by its conditional mean given the observed data;
Nile data
Initialisation – to smooth noise out of the observed series, we consider the conditional mean of Ys
General state space model
ARMA model
Comparison with ARIMA models
given all the data before and after it.
Summary
 However the state space algorithms are designed for iterative computation and so look
more complicated . . .

7 / 31
Local trend model

MATH11131 Part 5: State Space


models  The general derivation of the state space equations is algebraically messy, so we
State space models
Introduction
illustrate the ideas using a simple special case, the so-called local trend model (or
Basic Idea I
Basic Idea II
local level model).
Multivariate normal distribution
A useful lemma
⊲ Local trend model
 All linear state space models involve two equations, the state equation, which
Local trend model determines the evolution of an underlying unobserved state, and the observation
Filtering, prediction and smoothing
Notation and basic identities equation, which determines how the observed data are related to the state.
Kalman filter
Kalman filter
Kalman filter  The local trend model has
Nile data
Nile data
iid
Forecast errors
Implications of (2)
State equation : µt+1 = µt + ηt, ηt ∼ N (0, ση2 )
State error recursion
iid
State smoothing I
State smoothing II
Observation equation : yt = µt + εt , εt ∼ N (0, σ 2 )
Kalman filter and smoother
State smoothing III
Nile data where the ηt and εt are all mutually independent.
Missing values
Nile data
Initialisation  Thus the state µt performs a random walk, but is observed only with error
General state space model
ARMA model
Comparison with ARIMA models
 This is illustrated on the next slide.
Summary

8 / 31
Local trend model

MATH11131 Part 5: State Space


models Upper panel: evolution of underlying state according to state equation; middle panel:
State space models
Introduction
evolution of state equation, with observed data; lower panel: observed data, with two
Basic Idea I
Basic Idea II
sections missing.
Multivariate normal distribution
A useful lemma
Local trend model
⊲ Local trend model
Filtering, prediction and smoothing

0.0
Notation and basic identities

−0.5
Kalman filter
Kalman filter

mu

−1.0
Kalman filter

−1.5
Nile data
Nile data
0 20 40 60 80 100
Forecast errors
Time
Implications of (2)
State error recursion
State smoothing I
0.0

State smoothing II
−0.5

Kalman filter and smoother


−1.0

State smoothing III


Y

Nile data
−1.5

Missing values
Nile data 0 20 40 60 80 100

Initialisation Time

General state space model


ARMA model
Comparison with ARIMA models
0.0

Summary
−0.5
−1.0
−1.5

0 20 40 60 80 100

Time

9 / 31
Filtering, prediction and smoothing

MATH11131 Part 5: State Space


models  We suppose that data y1 , . . . , yn are available, let Ht = {y1 , . . . , yn } denote the
State space models
Introduction
information available at time t, and assume (for now) that the model, including the
Basic Idea I
Basic Idea II
parameter values, is known
Multivariate normal distribution
A useful lemma
Local trend model
 We aim to make inference about the underlying states µ1 , . . . , µn
Local trend model

⊲ Filtering, prediction and


smoothing
 Three problems are typically tackled:
Notation and basic identities
Kalman filter – filtering: we estimate µt using Ht
Kalman filter
Kalman filter
Nile data – prediction: we forecast µt+h for h > 0 using Ht
Nile data
Forecast errors
Implications of (2)
– smoothing: we estimate µt using Hn
State error recursion
State smoothing I
State smoothing II
to which we might add identification of the model structure, estimation of the
Kalman filter and smoother unknown parameters, and diagnosis of model failure!
State smoothing III
Nile data
Missing values  Analogy: you are trying to read bad handwriting on a blackboard during a lecture:
Nile data
Initialisation
General state space model
– filtering is deciphering the current word, using the lecture contents thus far;
ARMA model
Comparison with ARIMA models
Summary
– prediction is guessing what the next words will be, using the lecture contents thus
far;
– smoothing is deciphering a word in the middle of the board, using the entire lecture.

10 / 31
Notation and basic identities

MATH11131 Part 5: State Space


models  Let
State space models
Introduction – µt|j and Σt|j denote the conditional mean and variance of µt given Ht
Basic Idea I
Basic Idea II
Multivariate normal distribution – yt|j denote the conditional mean of yt given Ht
A useful lemma
Local trend model
Local trend model
– vt = yt − yt|t−1 and Vt = var(vt | Ht−1 ) be the one-step ahead forecast error and its
Filtering, prediction and smoothing
⊲ Notation and basic identities variance given Ht−1 .
Kalman filter
Kalman filter  The observation equation gives
Kalman filter
Nile data
Nile data
Forecast errors
yt|t−1 = E(yt | Ht−1 ) = E(µt + εt | Ht−1 ) = E(µt | Ht−1 ) , so
Implications of (2)
State error recursion
State smoothing I
State smoothing II
vt = yt − yt|t−1 = yt − µt|t−1 , Vt = var(yt − µt|t−1 | Ht−1 ) = · · · = Σt|t−1 + σ 2 ,
Kalman filter and smoother
State smoothing III and likewise conditioning on Ht−1 shows that vt is independent of y1 , . . . , yt−1 , because
Nile data
Missing values
Nile data
Initialisation E(vt ) = 0, cov(vt , yj ) = 0, j<t
General state space model
ARMA model
Comparison with ARIMA models
Summary
Thus conditional on Ht−1 , knowing vt is equivalent to knowing yt , so we can write
Ht = {Ht−1 , yt } ≡ {Ht−1 , vt }.
 The forecast error vt is independent of Ht−1 , so var(vt ) = var(vt | Ht−1 ).

11 / 31
Kalman filter

MATH11131 Part 5: State Space


models Lemma 3. For the local trend model, conditional on Ht−1 , we have
State space models
Introduction
     
Basic Idea I µt µt|t−1 Σt|t−1 Σt|t−1
Basic Idea II ∼ N2 ,
Multivariate normal distribution vt H 0 Σt|t−1 Vt
A useful lemma t−1
Local trend model
Local trend model
Filtering, prediction and smoothing and thus the conditional distribution of µt | Ht is normal with mean and variance
Notation and basic identities
⊲ Kalman filter
Kalman filter
Kalman filter
µt|t = µt|t−1 + Σt|t−1 vt /Vt = µt|t−1 + Kt vt , Σt|t = Σt|t−1 (1 − Kt )
Nile data
Nile data
Forecast errors where Kt ∈ (0, 1) is called the Kalman gain. Moreover, based on Ht , we have
Implications of (2)
State error recursion
State smoothing I
State smoothing II µt+1|t = µt|t , Σt+1|t = Σt|t + ση2 .
Kalman filter and smoother
State smoothing III
Nile data
Missing values
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

12 / 31
Kalman filter

MATH11131 Part 5: State Space


models The Kalman filter algorithm for the local trend model based on y1 , . . . , yn entails
State space models
Introduction
assuming that µ1 ∼ N (µ1|0 , Σ1|0 ), and then for t = 1, . . . , n iterating the computations
Basic Idea I
Basic Idea II
Multivariate normal distribution vt = yt − µt|t−1
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities Vt = Σt|t−1 + σ 2
Kalman filter
⊲ Kalman filter
Kalman filter
Nile data
Nile data
Kt = Σt|t−1 /Vt
Forecast errors
Implications of (2)
(1)
State error recursion
State smoothing I µt+1|t = µt|t−1 + Kt vt
State smoothing II
Kalman filter and smoother
State smoothing III
Nile data
Missing values
Σt+1|t = Σt|t−1 (1 − Kt ) + ση2
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

13 / 31
Kalman filter

MATH11131 Part 5: State Space


models  We take arbitrary initial values of 0 and 1 for µ1|0 and Σ1|0 , and need guesses for σ 2 and
State space models
Introduction
ση2
Basic Idea I
Basic Idea II
Multivariate normal distribution
 For the filter, we then iterate forward:
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
t yt µt|t−1 vt Σt|t−1 Vt Kt
Kalman filter
Kalman filter
1 y1 0 1
⊲ Kalman filter 2 y2
Nile data
Nile data 3 y3
Forecast errors
.. ..
Implications of (2)
State error recursion
. .
State smoothing I
State smoothing II
n − 1 yn−1
Kalman filter and smoother
State smoothing III
n yn
Nile data
Missing values
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

14 / 31
Nile data

MATH11131 Part 5: State Space


models Upper panel: data and filtered estimate of stated variable (red). Bottom panel: residuals
State space models
Introduction
Basic Idea I
Basic Idea II
Multivariate normal distribution

1400
A useful lemma
Local trend model
Local trend model

1000
Filtering, prediction and smoothing

Nile
Notation and basic identities
Kalman filter

600
Kalman filter
Kalman filter
⊲ Nile data
1880 1900 1920 1940 1960
Nile data
Forecast errors Time
Implications of (2)
State error recursion
State smoothing I
State smoothing II
Kalman filter and smoother
2

State smoothing III


1

Nile data
residuals

Missing values
0

Nile data
−3 −2 −1

Initialisation
General state space model
ARMA model
Comparison with ARIMA models 1880 1900 1920 1940 1960
Summary
Time

Measurements of the annual flow of the river Nile at Aswan (formerly Assuan), 1871-1970,
in 108 m3 .

15 / 31
Nile data

MATH11131 Part 5: State Space


models Time series diagnostics for fit of state space model to Nile data
State space models
Introduction
Basic Idea I
Basic Idea II
Standardized Residuals
Multivariate normal distribution
A useful lemma

2
Local trend model

1
Local trend model

0
−3 −2 −1
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
1880 1900 1920 1940 1960
Kalman filter
Time
Kalman filter
Nile data ACF of Residuals
⊲ Nile data

1.0
Forecast errors
Implications of (2)
0.6
ACF

State error recursion 0.2

State smoothing I
State smoothing II
−0.2

Kalman filter and smoother 0 5 10 15 20


State smoothing III Lag
Nile data
Missing values p values for Ljung−Box statistic
Nile data
0.0 0.2 0.4 0.6 0.8 1.0

Initialisation
General state space model
p value

ARMA model
Comparison with ARIMA models
Summary
2 4 6 8 10

lag

16 / 31
Forecast errors

MATH11131 Part 5: State Space


models  Given the initial values Σ1|0 and µ1|0 , which are independent of the data, we use the
State space models
Introduction
data to write one-step ahead forecast errors as
Basic Idea I
Basic Idea II
v1 = y1 − µ1|0
Multivariate normal distribution
A useful lemma v2 = y2 − µ2|1 = y2 − µ1|0 − K1 (y1 − µ1|0 )
Local trend model
Local trend model v3 = y3 − µ3|2 = y3 − µ1|0 − K2 (y2 − µ1|0 ) − K1 (1 − K2 )(y1 − µ1|0 ) and so on.
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
 We write this in matrix form as
Kalman filter
Kalman filter
Nile data
Nile data
v = K (y − µ1|0 1n ), (2)
⊲ Forecast errors

where v T = (v1 , . . . , vn ), y T = (y1 , . . . , yn ), 1n is a n × 1


Implications of (2)
State error recursion vectore of ones, and
State smoothing I
State smoothing II

0 ··· 0
 
Kalman filter and smoother
State smoothing III
1 0
Nile data
Missing values
 k21 1 0 ··· 0 
 k.31 k.32 1 ·.· · 0.
 
Nile data
Initialisation
K= 
 .. .. . . ..
General state space model

ARMA model

Comparison with ARIMA models
Summary kn1 kn2 kn3 · · · 1

where ki,i−1 = −Ki−1 , kij = −(1 − Ki−1 )(1 − Ki−2 ) · · · (1 − Kj+1 )Kj ,
for i = 2, . . . , n and j = 1, . . . , i − 2.

17 / 31
Implications of (2)

MATH11131 Part 5: State Space


models Lemma 4. The one-step-ahead forecast errors v1 , . . . , vn are mutually independent normal
State space models
Introduction
random variables, and the matrix K provides a Cholesky decomposition of Σ = var(y):
Basic Idea I

KΣK T = diag(V1 , . . . , Vn ).
Basic Idea II
Multivariate normal distribution
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
 This suggests how to compute the likelihood from the data, as
Notation and basic identities
Kalman filter
n
Kalman filter Y
Kalman filter
Nile data
f (y1 , . . . , yn ; θ) = f (vt ; θ),
Nile data
Forecast errors
i=1
⊲ Implications of (2)
State error recursion
State smoothing I where vt ∼ N (0, Vt ), and the variances Vt depend on the parameters θ = (σ 2 , ση2 ); we
State smoothing II
Kalman filter and smoother assume that µ1|0 and Σ1|0 are known.
State smoothing III
Nile data
Missing values
 For the river Nile, we find σ̂ 2 = 15098.577, σ̂η2 = 1469.147, so the changes in the state
Nile data
Initialisation
due to the ‘state innovation’ ηt are dwarfed by the ‘observation error’ εt .
General state space model
ARMA model
Comparison with ARIMA models
 It is not uncommon to find variance estimates of zero, so care is needed.
Summary
 Parameter estimation for many other time series is implemented analogously to this.

18 / 31
State error recursion

MATH11131 Part 5: State Space


models  Define xt = µt − µt|t−1 to be the forecast of the state variable µt , given Ht−1 .
State space models
Introduction
Basic Idea I
 Evidently var(xt | Ht−1 ) = var(µt | Ht−1 ) = Σt|t−1 , and the Kalman filter gives that
Basic Idea II
Multivariate normal distribution
A useful lemma vt = yt − µt|t−1 = µt + εt − µt|t−1 = xt + εt .
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
 Now we get a recursion for xt , as follows:
Kalman filter
Kalman filter
Kalman filter xt+1 = µt+1 − µt+1|t = µt + ηt − (µt|t−1 + Kt vt )
Nile data
Nile data
Forecast errors
= xt + ηt − Kt vt = xt + ηt − Kt (xt + εt )
Implications of (2)
⊲ State error recursion = (1 − Kt )xt + ηt − Kt εt
State smoothing I
State smoothing II
Kalman filter and smoother and so we have ‘observation’ and ‘state’ equations
State smoothing III
Nile data
Missing values
Nile data
vt = xt + εt, xt+1 = Lt xt + ηt − Kt εt, t = 1, . . . , n,
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
where Lt = 1 − Kt = 1 − Σt|t−1 /Vt = (Vt − Σt|t−1 )/Vt = σ 2 /Vt and x1 = µ1 − µ1|0
Summary

19 / 31
State smoothing I

MATH11131 Part 5: State Space


models
 The goal is now to estimate the state variables µ1 , . . . , µn based on y1 , . . . , yn : we seek
State space models to compute the (multivariate normal) distribution of µt | Hn , for each t we seek
Introduction
Basic Idea I conditional mean and variance µt|n and Σt|n , here called the smoothed state mean
Basic Idea II
Multivariate normal distribution and the smoothed state variance.
A useful lemma
Local trend model  We use the following facts:
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
– the v1 , . . . , vn are mutually independent functions of y1 , . . . , yn
Kalman filter
Kalman filter
– if y1 , . . . , yn are fixed, then Ht−1 and v1 , . . . , vn are fixed, and vice versa.
Kalman filter
Nile data
– vt , . . . , vn are independent of Ht−1 with mean zero and var(vj ) = Vj , for each j ≥ t
Nile data
Forecast errors  We apply Lemma 2 (c) to the conditional joint distribution of µt , vt , . . . , vn given Ht−1 ,
and obtain, with Y ≡ Ht−1 and Z = (v1 , . . . , vn )T ,
Implications of (2)
State error recursion
⊲ State smoothing I
State smoothing II
Kalman filter and smoother
State smoothing III
µt|n = E(µt | Ht−1 , vt , . . . , vn )
Nile data  T  −1  
Missing values
Nile data
cov(µt , vt ) Vt 0 ··· 0 vt
Initialisation  cov(µt , vt+1 )   0 Vt+1 · · · 0   vt+1 
General state space model = µt|t−1 +      
ARMA model
Comparison with ARIMA models
 ···   ··· ··· ···   ··· 
Summary cov(µt , vn ) 0 0 · · · Vn vn
Xn
= µt|t−1 + cov(µt , vj )Vj−1 vj (3)
j=t

20 / 31
State smoothing II

 To compute µt|n we need cov(µt , vj ) = cov(xt , vj ), because E(µt|t−1 εj ) = 0 for any


MATH11131 Part 5: State Space
models
j ≥ t, and as E(vj ) = 0, cov(xt , vj ) = E(xt (xj + εj )), which equals
State space models
Introduction
Basic Idea I var(xt ) = Σt|t−1 , j = t,
Basic Idea II
Multivariate normal distribution E(xt (Lt xt + ηt − Kt εt )) = Σt|t−1 Lt , j = t + 1,
A useful lemma
Local trend model j−1
Y
Local trend model
Filtering, prediction and smoothing E(xt (Lj−1 xj−1 + ηj−1 − Kj−1 εj−1 )) = Σt|t−1 Li , j = t + 2, . . . , n,
Notation and basic identities
Kalman filter i=t
Kalman filter
Kalman filter
Nile data
Nile data
and consequently (3) becomes µt|n = µt|t−1 + Σt|t−1 qt−1 where
Forecast errors
Implications of (2)
n−1
!
State error recursion
vt vt+1 vt+2 Y vn
State smoothing I
⊲ State smoothing II qt−1 = + Lt + Lt Lt+1 + ··· + Lj
Kalman filter and smoother
Vt Vt+1 Vt+2 j=t
Vn
State smoothing III
Nile data
Missing values
Nile data  We thus obtain a backwards recursion to compute the smoothed state variables:
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
qt−1 = Vt−1 vt + Lt qt , µt|n = µt|t−1 + Σt|t−1 qt−1 , t = n, . . . , 1,
Summary

where qn = 0, and µt|t−1 , Σt|t−1 , and Lt = 1 − Kt are available from the forward pass of
the Kalman filter (1)

21 / 31
Kalman filter and smoother

MATH11131 Part 5: State Space


models  We take arbitrary initial values of 0 and 1 for µ1|0 and Σ1|0 , and need guesses for σ 2 and
State space models
Introduction
ση2
Basic Idea I
Basic Idea II
Multivariate normal distribution
 For the filter, we then iterate forward:
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
t yt µt|t−1 vt Σt|t−1 Vt Kt Lt qt µt
Kalman filter
Kalman filter
1 y1 0 1
Kalman filter
Nile data
2 y2
Nile data 3 y3
Forecast errors
.. ..
Implications of (2)
State error recursion
. .
State smoothing I
State smoothing II
n − 1 yn−1
⊲ Kalman filter and smoother n yn 0
State smoothing III
Nile data
Missing values
Nile data  For the smoother, we need an initial value of qn (here 0), then we iterate backwards.
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

22 / 31
State smoothing III

MATH11131 Part 5: State Space


models  Similar manipulations give a recursion to compute the conditional variance Σt|n of µt
State space models
Introduction
given y1 , . . . , yn , as follows:
Basic Idea I

Mt−1 = Vt−1 + L2t Mt ,


Basic Idea II
Multivariate normal distribution Σt|n = Σt|t−1 − Σ2t|t−1 Mt−1 , t = n, . . . , 1,
A useful lemma
Local trend model
Local trend model
Filtering, prediction and smoothing
where we take initial value Mn = 0.
Notation and basic identities
Kalman filter
Kalman filter
Kalman filter
Nile data  The figure on the next slide shows the difference between filtering and smoothing
Nile data
Forecast errors
Implications of (2)
State error recursion
State smoothing I  Prediction of the next value is based on µn+1|n , with variance Σn+1|n for the predicted
State smoothing II
Kalman filter and smoother mean µn+1 , and variance Σn+1|n + σ 2 for the next observation yn+1 = µn+1 + εn+1 .
⊲ State smoothing III
Nile data
Missing values
Nile data
Initialisation
General state space model
ARMA model
Comparison with ARIMA models
Summary

23 / 31
Nile data

MATH11131 Part 5: State Space


models Top panel: data yt and filtered estimate of stated variable µt|t−1 (red). Bottom panel: data
State space models
Introduction
and smoothed state variable µt|n
Basic Idea I
Basic Idea II
Multivariate normal distribution
A useful lemma
Local trend model

1400
Local trend model
Filtering, prediction and smoothing
Notation and basic identities

1000
Kalman filter

Nile
Kalman filter
Kalman filter

600
Nile data
Nile data
Forecast errors
1880 1900 1920 1940 1960
Implications of (2)
State error recursion Time
State smoothing I
State smoothing II
Kalman filter and smoother
1400

State smoothing III


⊲ Nile data
Missing values
1000

Nile data
Nile

Initialisation
General state space model
ARMA model
600

Comparison with ARIMA models


Summary
1880 1900 1920 1940 1960

Time

24 / 31
Missing values

MATH11131 Part 5: State Space


models  Suppose that the observations yl+1 , . . . , yl+h are missing, with l ∈ {1, . . . , n} and h ≥ 1.
State space models
Introduction
 We can use the state equation to write the state for a missing observation as
Basic Idea I
Basic Idea II
Multivariate normal distribution
t
X
A useful lemma
Local trend model
µt = µt−1 + ηt = . . . = µl + ηj
Local trend model
Filtering, prediction and smoothing
j=l+1
Notation and basic identities
Kalman filter
Kalman filter where the sum equals zero if l + 1 > t − 1.
Kalman filter
Nile data  This implies that for missing observations, we have
Nile data
Forecast errors
Implications of (2)
State error recursion
E(µt | Ht−1 ) = E(µt | Hl ) = µl+1|l var(µt | Ht−1 ) = var(µt | Hl ) = Σl+1|l + ση2 ,
State smoothing I
State smoothing II
Kalman filter and smoother and this yields the recursion
State smoothing III
Nile data µt|t−1 = µt−1|t−2
⊲ Missing values
Nile data
Initialisation Thus for missing observations we apply the Kalman recursion (1) with vt = 0, Kt = 0.
General state space model
ARMA model
Comparison with ARIMA models
Summary

25 / 31
Nile data

MATH11131 Part 5: State Space


models Top panel: data yt , with missing values, and filtered state variable µt|t−1 . Bottom panel:
State space models
Introduction
data, with missing values, and smoothed state variable µt|n .
Basic Idea I
Basic Idea II
Multivariate normal distribution
A useful lemma
Local trend model

1400
Local trend model
Filtering, prediction and smoothing
Notation and basic identities

1000
Kalman filter

Nile
Kalman filter
Kalman filter

600
Nile data
Nile data
Forecast errors
1880 1900 1920 1940 1960
Implications of (2)
State error recursion Time
State smoothing I
State smoothing II
Kalman filter and smoother
1400

State smoothing III


Nile data
Missing values
⊲ Nile data
1000
Nile

Initialisation
General state space model
ARMA model
600

Comparison with ARIMA models


Summary
1880 1900 1920 1940 1960

Time

26 / 31
Initialisation
 The Kalman filter is initialised by taking µ1 ∼ N (µ1|0 , Σ1|0 ). Now we discuss the choice
MATH11131 Part 5: State Space of µ1|0 and Σ1|0 .
models

State space models


Introduction
Basic Idea I
 Since v1 = y1 − µ1|0 and Σ1 = Σ1|0 + σ 2 , we get
Basic Idea II
Multivariate normal distribution
A useful lemma Σ1|0 Σ1|0 2 2
Local trend model µ1|1 = µ1|0 + 2
(y1 − µ1|0 ), Σ1|1 = 2
σ + σ η
Local trend model Σ1|0 + σ Σ1|0 + σ
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
Kalman filter
Thus taking a diffuse prior by letting Σ1|0 → ∞ is equivalent to assuming that
Kalman filter
Nile data
µ1 ∼ N (y1 , σ 2 ).
Nile data
Forecast errors
Implications of (2)  This is called diffuse initialisation and amounts to treating y1 as fixed.
State error recursion
State smoothing I
State smoothing II
Kalman filter and smoother  For the state smoothing, we get
State smoothing III
Nile data 2
Σ1|0 Σ1|0 Σ1|0
Missing values

2 2
Nile data
⊲ µ1|n = µ1|0 + 2
(v1 + σ q1 ), Σ1|n = 2
σ − σ 4 M1
Initialisation
General state space model Σ1|0 + σ Σ1|0 + σ Σ1|0 + σ 2
ARMA model
Comparison with ARIMA models
Summary
so letting Σ1|0 → ∞ gives µ1|n = y1 + σ 2 q1 , and Σ1|n = σ 2 − σ 4 M1 .

 If setting Σ1|0 = ∞ is problematic, one may need to estimate µ1 in the same way as the
other parameters.

27 / 31
General state space model

MATH11131 Part 5: State Space


models  Many models, including ARIMA models, can be written in the general state space form
State space models
Introduction
iid
Basic Idea I
Basic Idea II
State equation : µt+1 = Tt µt + Rt ηt , ηt ∼ Nm (0, Qt )
Multivariate normal distribution iid
A useful lemma Observation equation : yt+1 = Zt µt + εt , εt ∼ Np (0, Ht )
Local trend model
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
where the yt have dimension p × 1, the ηt have dimension m × 1, and the ηt and εt are
Kalman filter
Kalman filter
all mutually independent.
Kalman filter
Nile data
Nile data
Forecast errors
 The matrices Tt , Rt , Qt , Zt , Ht are supposed known initially but may contain parameters
Implications of (2)
State error recursion
to be estimated, and we suppose that µ1 ∼ N (a1 , P1 ), independently of the εt and ηt .
State smoothing I
State smoothing II
Kalman filter and smoother  The matrices Zt and Tt−1 may depend on Ht−1 , and often Rt = Im .
State smoothing III
Nile data
Missing values
Nile data
 The state equation is a first-order autoregression, and hence a first-order Markov
Initialisation
⊲ General state space model
process, and the observation equation is a linear regression model, but with correlated
ARMA model
Comparison with ARIMA models
variables.
Summary

 Essentially, all the previous computations go through again, but with a lot of linear
algebra—see, for example, Shumway and Stoffer: Time Series Analysis and Its
Applications: With R Examples (2006, Chapter 6)

28 / 31
ARMA model
 Consider the ARMA(p, q) model written in the form
MATH11131 Part 5: State Space
models r−1
X r−1
X
State space models
Introduction yt = φj yt−j + εt + θj εt−j , t = 1, . . . , n,
Basic Idea I
Basic Idea II j=1 j=1
Multivariate normal distribution
A useful lemma
Local trend model where r = max(p, q + 1) and for which some of the coefficients are zero.
Local trend model
Filtering, prediction and smoothing  We set
Notation and basic identities
Kalman filter
Kalman filter
Kalman filter Zt = (1 0 0 · · · 0),
Nile data  
Nile data yt
Forecast errors
Implications of (2)
 φ2 yt−1 + · · · + φr yt−r+1 + θ1 εt + · · · + θr−1 εt−r+2 
State error recursion

 φ3 yt−1 + · · · + φr yt−r+2 + θ2 εt + · · · + θr−1 εt−r+3


 
State smoothing I µt =  
State smoothing II .. 
Kalman filter and smoother
State smoothing III
 . 
Nile data
Missing values
φr yt−1 + θr−1 εt
Nile data    
Initialisation φ1 1 0 1
General state space model
⊲ ARMA model  ... . . . ...   θ1 
Comparison with ARIMA models Tt ≡ T = 
 φr−1 0
 , Rt ≡ R =  .  ,
 ..  ηt = εt+1, Ht ≡ 0
Summary 1
φr 0 0 θr−1

 With the observation equation yt = Zt µt , this gives the ARMA(p, q) model.

29 / 31
Comparison with ARIMA models

MATH11131 Part 5: State Space


models  ARMA models
State space models
Introduction – are empirical models, not based on the structure of the underlying system
Basic Idea I
Basic Idea II – provide a simple flexible black box approach to modelling, based on empirical
Multivariate normal distribution
A useful lemma considerations (ACF, PACF, AIC, . . .)
Local trend model
Local trend model – can deal with seasonality and trend
Filtering, prediction and smoothing
Notation and basic identities – are easily fitted using standard software
Kalman filter
Kalman filter – can easily be used for forecasting
Kalman filter
Nile data
Nile data
Forecast errors
 State space models
Implications of (2)
State error recursion – enable knowledge of the underlying system to be built in
State smoothing I
State smoothing II – require thought about the problem, to give an appropriate structure
Kalman filter and smoother
State smoothing III – can deal with seasonality and trend
Nile data
Missing values – extend in obvious ways to multivariate data
Nile data
Initialisation – can be fitted to a wider class of nonlinear models, using the Markov structure and
General state space model
ARMA model particle filters
⊲ Comparison with ARIMA models
Summary – are not so easy to understand(?)
– are not so easy to fit, because software is less widely available.

30 / 31
Summary

MATH11131 Part 5: State Space


models  State space modelling provides a very general approach to time series, encompassing
State space models
Introduction
very many time-domain approaches.
Basic Idea I
Basic Idea II
Multivariate normal distribution  They enable problem-specific information about the structure of the model to be built in
A useful lemma
Local trend model to the formulation.
Local trend model
Filtering, prediction and smoothing
Notation and basic identities
Kalman filter
 These are models with unobserved Markovian structure, to which is added observational
Kalman filter
Kalman filter
noise.
Nile data
Nile data
Forecast errors
Implications of (2)
 The calculations involve recursive algorithms
State error recursion
State smoothing I – which are explicit in the linear Gaussian case,
State smoothing II
Kalman filter and smoother – but require integration or other approximations to integrals in general
State smoothing III
Nile data
Missing values
Nile data
 They are Formula One time series models: not very available, not so easy to drive, but
Initialisation
General state space model
much more powerful than the family saloon, once you know how they work.
ARMA model
Comparison with ARIMA models
⊲ Summary

31 / 31

You might also like