17
Linear Gaussian State Space Models Structural Time Series Models Level and Trend Models Basic Structural Model (BSM) Dynamic Linear Models State Space Model Representation Level, Trend, and Seasonal Models Time Varying Regression Model Extensions Multivariate Time Series Analysis Bayesian Time Series Analysis 1 Time Series Data Analysis Using R

Linear Gaussian State Space Models - Portland State …web.pdx.edu/~crkl/WISE2016/TSAR-2.pdfDynamic Linear Models •Local Trend Model 2 –State Space Model Representation Time Series

Embed Size (px)

Citation preview

Linear Gaussian State Space Models

• Structural Time Series Models

– Level and Trend Models

– Basic Structural Model (BSM)

• Dynamic Linear Models

– State Space Model Representation

• Level, Trend, and Seasonal Models

• Time Varying Regression Model

– Extensions

• Multivariate Time Series Analysis

• Bayesian Time Series Analysis

1 Time Series Data Analysis Using R

Structural Time Series Models

• Local level Model

• Local Trend Model

2 Time Series Data Analysis Using R

2

1

2

1

, ~ (0, )

, ~ (0, )

t t t t v

t t t t w

y v v N

w w N

2

1

2

1 1 , ,

2

1 , ,

, ~ (0, )

, ~ (0, )

, ~ (0, )

t t t t v

t t t t t

t t t t

y v v N

w w N

w w N

Structural Time Series Models

• Basic Structural Model (BSM)

• Forecasting

3 Time Series Data Analysis Using R

2

1 1, 1

2

1 1 , ,

2

1 , ,

12

1, , 1 , ,

2

, , 1

, ~ (0, )

, ~ (0, )

, ~ (0, )

, ~ (0, )

, 2,..., 1

t t t t t v

t t t t t

t t t t

p

t j t t t

j

j t j t

y v v N

w w N

w w N

w w N

j p

1| 1

|

ˆ , 1,2,...,

ˆ , 1,2,...

t t t t t p

n h n n n n h p

y a b s t n

y a hb s h p

Dynamic Linear Models

• Observation Equation

• State Equation

• Initial State Distribution

4 Time Series Data Analysis Using R

11 1 1 1

, ~ (0 , )t t t t t tmm m p p m m m m

y F v v iid N V

111 1 1 1

, ~ (0 , )t t t t t tpp p p p p p p p

G w w iid N W

0 0 0

' '

0 0

'

~ ( , )

( ) ( ) 0

( ) 0 ,

t t

t sm p

N m C

E v E w t

E v w t s

Dynamic Linear Models

• Local Level Model

– State Space Model Representation

5 Time Series Data Analysis Using R

2

2

1

, ~ (0, )

, ~ (0, )

t t t t v

t t t t w

y v v N

w w N

1

2 2

( 1, 1)

, 1, 1, ,

t t t t

t t t t

t t t t t v t w

y F v

G w m p

F G V W

Dynamic Linear Models

• Local Trend Model

– State Space Model Representation

6 Time Series Data Analysis Using R

2

2

1 1 , ,

2

1 , ,

, ~ (0, )

, ~ (0, )

, ~ (0, )

t t t t v

t t t t t

t t t t

y v v N

w w N

w w N

1

2

2

2

( 1, 2)

01 1, 1 0 , , ,

00 1

t t t t

t t t t

t

t t t t v t

t

y F v

G w m p

F G V W

,1

,1

1 1

0 1

tt t

tt t

w

w

Dynamic Linear Models

• Time Varying Regression Parameters

– State Space Model Representation

7 Time Series Data Analysis Using R

2

2

1 , ,

2

1 , ,

, ~ (0, )

, ~ (0, )

, ~ (0, )

t t t t t t v

t t t t

t t t t

y x v v N

w w N

w w N

2

2, ,1

2, ,1

1 01 1 , ,

0 1

01 0, ,

00 1

t

t t t t t t t v

t

t tt t t

t t t

t tt t t

y x v F x G V

w ww W

w w

Dynamic Linear Models

• Model Estimation

– Filtering (filtered estimate of )

– Smoothing (smoothed estimate of )

8 Time Series Data Analysis Using R

1

{ }t t t t

t

t t t t

y F vy

G w

1( | { ,..., })t t tE I y y

1( | { ,..., })t T TE I y y

Model Estimation

• The Kalman Filter is a set of recursion equations for determining the optimal estimates of t given It. The filter consists of two sets of equations:

– Prediction Equation

– Update Equation

• Using the following notations

9 Time Series Data Analysis Using R

'

( | )

[( )( ) | )

t t t t t

t t t t t t t

m E I optimal estimator of based on I

C E m m I MSE matrix of m

Model Estimation

• Prediction Equations – Given mt-1 and Ct-1 at t-1, the optimal predictor of t and its

MSE matrix are

– The corresponding optimal predictor of yt at t-1 is

– The predictive error and its MSE matrix are

10 Time Series Data Analysis Using R

| 1 1 1

' '

| 1 1 1 1 1

( | )

[( )( ) | )

t t t t t t

t t t t t t t t t t t

m E I G m

C E m m I G C G W

| 1 1 | 1[ | ]t t t t t t ty E y I Fm

| 1 | 1 | 1

' '

| 1

( )

( )

t t t t t t t t t t t t t

t t t t t t t t

e y y y F m F m v

E e e Q FC F V

Model Estimation

• Update Equations – When new observation yt become available, the optimal

predictor mt|t-1 and its MSE matrix are updated using

– Kalman Gain Matrix gives the weight on new information et in the update equation for mt.

11 Time Series Data Analysis Using R

' 1

| 1 | 1 | 1

' 1

| 1 | 1

' 1

| 1 | 1 | 1

' 1

| 1

( )

:

t t t t t t t t t t t

t t t t t t t

t t t t t t t t t t

t t t t t

m m C F Q y F m

m C F Q e

C C C F Q FC

Note K C F Q Kalman Gain Matrix

Model Estimation

• Kalman Smoother – Once all data IT is observed, the optimal estimators E(t|IT)

can be computed using the backwards Kalman smoothing recursions

– The algorithm starts by setting mT|T = mT and CT|T = CT and then proceed backwards for t = T-1, …,1.

12 Time Series Data Analysis Using R

*

| 1| 1

' * *'

| | | 1| 1|

* ' 1

1 1|

( | ) ( )

[( )( ) | ) ( )

t T t T t t t T t t

t t T t t T T t T t t T t t t

t t t t t

E I m m C m G m

E m m I C C C C C

C C G C

Maximum Likelihood Estimation

• For a linear Gaussian state space model, let y denote the parameters of the model (embedded in the system matrices Ft, Gt, Vt, and Wt). The prediction error decomposition of the Gaussian log-likelihood function is

13 Time Series Data Analysis Using R

1

1

' 1

1 1

ln ( | ) ln ( | ; )

1 1ln(2 ) ln | ( ) | ( ) ( ) ( )

2 2 2

ˆ arg max ln ( | )

T

t t

t

N N

t t t t

t t

MLE

L y f y I

NTQ e Q e

L yy

y y

y y y y

y y

| 1 | 1

| 1 | 1

1/2 ' 1

| 1

~ ( ( ) ( ), ( ))

( ) ( ) ( ) ~ (0, ( ))

1( ; ) (2 ( )) exp ( ) ( ) ( )

2

t t t t t t

t t t t t t t t t

t t t t t t

y N F m Q

e y y y F m N Q

f y Q e Q e

y y y

y y y y

y y y y y

Forecasting

• The Kalman filter prediction equations produces in-sample 1-step ahead forecasts and MSE matrices.

• Out-of-sample h-step ahead predictions and MSE matrices can be computed from the prediction equations by extending the data set y1, …, yT with a set of h missing values.

• When yt is missing the Kalman filter reduces to the prediction step so a sequence of h missing values at the end of the sample will produce a set of h-step ahead forecasts

Time Series Data Analysis Using R

Forecasting

• One-Step Ahead Forecast at t = p, p+1,…

15 Time Series Data Analysis Using R

1| 1

1|0 0 0 1

2|1 1 1 2

| 1 1 1 0

ˆ

ˆ

ˆ

...

ˆ

t t t t t p

p

p

p p p p

y a b s

y a b s

y a b s

y a b s

1| 1 1|

1|

1| 1

2

1|

2

1|

2

1| 1

ˆ ˆ

ˆ(| |)

ˆ100 (| / |)

ˆ( )

ˆ( )

ˆ100 [( / ) ]

t t t t t

t t

t t t

t t

t t

t t t

y y

MAE mean

MAPE mean y

MSE mean

RMSE mean

RMSPE mean y

Example 1 (Continued)

• China Shanghai Common Stock

– High Frequency Daily Index

– Monthly Index Time Series

• Trend, Seasonality

– Dynamic Linear Model

• Correlation with Exchange Rate?

16 Time Series Data Analysis Using R

Example 2

• Chinese Yuan vs. U.S. Dollar

– Exchange Rate Time Series

• Trend

• Intervention

– Dynamic Linear Model

• Correlation with Stock Market?

• ARMA

17 Time Series Data Analysis Using R