• Keine Ergebnisse gefunden

Applied Time Series Analysis

N/A
N/A
Protected

Academic year: 2022

Aktie "Applied Time Series Analysis"

Copied!
28
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

1

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Marcel Dettling

Institute for Data Analysis and Process Design Zurich University of Applied Sciences

marcel.dettling@zhaw.ch http://stat.ethz.ch/~dettling

ETH Zürich, April 7, 2014

(2)

Applied Time Series Analysis

SS 2014 – Week 08

Non-Stationary Models: ARIMA and SARIMA

Why?

We have seen that many time series we encounter in prac- tice show trends and/or seasonality. While we could de-

compose them and model the stationary part, it might also be attractive to directly model a non-stationary series.

How does it work?

There is a mechanism, "the integration" or "the seasonal integration" which takes care of the deterministic features, while the remainder is modeled using an ARMA(p,q).

There are some peculiarities!

see blackboard!

(3)

3

Applied Time Series Analysis

SS 2014 – Week 08

Example: Monthly Oil Prices

Time

oil.price

1990 1995 2000 2005

102030405060

Monthly Price for a Barrel of Crude Oil

(4)

Applied Time Series Analysis

SS 2014 – Week 08

Taking the Logarithm is Key

Time

log(Price)

1990 1995 2000 2005

2.53.03.54.0

Logged Monthly Price for a Crude Oil Barrel

(5)

5

Applied Time Series Analysis

SS 2014 – Week 08

Differencing Yields a Stationary Series

Time

Differences

1990 1995 2000 2005

-0.4-0.20.00.20.4

Differences of Logged Monthly Crude Oil Prices

(6)

Applied Time Series Analysis

SS 2014 – Week 08

ARIMA(p,d,q)-Models

Idea: Fit an ARMA(p,q) to a time series where the d

th

order difference with lag 1 was taken before.

Example: If , then

Notation: With backshift-operator B()

Stationarity: ARIMA-models are usually non-stationary!

Advantage: it‘s easier to forecast in R!

1

(1 ) ~ ( , )

t t t t

YXX

  B X ARMA p q

( )(1 B B )

d

X

t

( ) B E

t

   

~ ( ,1, )

X

t

ARIMA p q

(7)

7

Applied Time Series Analysis

SS 2014 – Week 08

ACF/PACF of the Differenced Series

0.0 0.5 1.0 1.5 2.0

-1.0-0.50.00.51.0

Lag

ACF

ACF

0.5 1.0 1.5 2.0

-1.0-0.50.00.51.0

Lag

Partial ACF

PACF

(8)

Applied Time Series Analysis

SS 2014 – Week 08

Fitting an ARIMA in R

We start by fitting an ARIMA(1,1,2) to the oil series:

> arima(lop, order=c(1,1,2)) Call:

arima(x = lop, order = c(1, 1, 2)) Coefficients:

ar1 ma1 ma2 0.8429 -0.5730 -0.3104 s.e. 0.1548 0.1594 0.0675

sigma^2 = 0.0066: ll = 261.88, aic = -515.75

(9)

9

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Alternative Fitting

Instead of fitting an ARIMA(1,1,2) to the logged oil series, we can also take the differenced log-oil series and fit an ARMA(1,2) to it.

IMPORTANT:

In this case, we have to do fitting without including an intercept (why?), thus:

> arima(diff(log(oil.price)), order=c(1,0,2),

include.mean=FALSE)

(10)

Applied Time Series Analysis

SS 2014 – Week 08

Meaning of the Model / Recipe

We can rewrite the ARIMA(1,1,2) model as an ARMA(2,2), see blackboard...

Some guidelines on how to fit ARIMA models to observed

time series can also be found on the blackboard...

(11)

11

Applied Time Series Analysis

SS 2014 – Week 08

Residual Analysis of the ARIMA(1,1,2)

0.0 0.5 1.0 1.5

0.00.20.40.60.81.0

Lag

ACF

ACF

0.5 1.0 1.5

-0.100.000.10

Lag

Partial ACF

PACF

(12)

Applied Time Series Analysis

SS 2014 – Week 08

SARIMA(p,d,q)(P,D,Q) s

= a.k.a. Airline Model. We are looking at the log-trsf. airline data

Log-Transformed Airline Data

Time

AirPassengers

1950 1952 1954 1956 1958 1960

100200300400600

(13)

13

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Seasonal Differencing Helps…

or at the log-transformed Australian Beer Production

Time

diff(lap, lag = 12)

1950 1952 1954 1956 1958 1960

0.00.10.20.3

Seasonally Differenced Airline Passenger Series

(14)

Applied Time Series Analysis

SS 2014 – Week 08

… But More Is Needed!

or at the log-transformed Australian Beer Production

Time

diff(diff(lap, lag = 12))

1950 1952 1954 1956 1958 1960

-0.15-0.050.050.15

Differenced Seasonally Differenced Airline Passenger Series

(15)

15

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

SARIMA(p,d,q)(P,D,Q) s

We perform some differencing… ( see blackboard)

(16)

Applied Time Series Analysis

SS 2014 – Week 08

ACF/PACF of SARIMA(p,d,q)(P,D,Q) s

Time

series

1950 1952 1954 1956 1958 1960

-0.15-0.10-0.050.000.050.100.150.00.51.0

Lag k

Auto-Korr.

0 5 10 15 20 -0.4-0.10.2

Lag k

part. Autokorr

1 5 10 15 20

(17)

17

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Modeling the Airline Data

Since there are “big gaps” in ACF/PACF:

This is an MA(13)-model with many coefficients equal to 0, or equivalently, a SARIMA(0,1,1)(0,1,1)

12

.

Note: Every SARIMA(p,d,q)(P,D,Q)

s

can be written as an ARMA(p+sP,q+sQ), where many coefficients will be equal to 0.

12

1 1

(1 )(1 )

t t

Z    B   B E

1 1 1 12 1 1 13

t t t t

EE

E

  E

   

(18)

Applied Time Series Analysis

SS 2014 – Week 08

SARIMA(p,d,q)(P,D,Q) s

The general notation is:

Interpretation:

- one typically chooses d=D=1

- s = periodicity in the data (season)

- P,Q describe the dependency on multiples of the period

see blackboard...

(1 ) (1 )

( ) ( ) ( ) ( )

d s D

t t

s s

s t s t

Z B B X

B B Z B B E

  

    

(19)

19

Applied Time Series Analysis

SS 2014 – Week 08

Forecasting Airline Data

Time

log(AP)

1955 1956 1957 1958 1959 1960 1961

5.65.86.06.26.4

Forecast of log(AP) with SARIMA(0,1,1)(0,1,1)

(20)

Applied Time Series Analysis

SS 2014 – Week 08

Residual Analysis of SARIMA(0,1,1)(0,1,1)

0.0 0.5 1.0 1.5

-0.20.00.20.40.60.81.0

Lag

ACF

ACF

0.5 1.0 1.5

-0.15-0.050.050.15

Lag

Partial ACF

PACF

(21)

21

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Outlook to Non-Linear Models

What are linear models?

Models which can be written as a linear combination of i.e. all AR-, MA- and ARMA-models

What are non-linear models?

Everything else, e.g. non-linear combinations of ,

terms like in the linear combination, and much more!

Motivation for non-linear models?

- modeling cyclic behavior with quicker increase then decrease - non-constant variance, even after transforming the series

X

t

X

t 2

X

t

(22)

Applied Time Series Analysis

SS 2014 – Week 08

SMI Log-Returns

SMI Log-Returns

Time

lret.smi

2500 3000 3500 4000

-0.08-0.040.000.04

(23)

23

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Normal Plot of SMI Log-Returns

+ +

+ + +

+ +

+

+ + + + ++

+ +

+ + ++++ ++ ++ + ++

+ + + +

+

+

+ + + ++

+

+ + + + +

+ +

+ ++ + ++ +

+ +

+ + ++

+ +

+ ++ +

+ + + ++ + ++ +

+ + +

+ ++ + +

+ + + +++

++ +

+ +

+ + + +

+ +

+ + ++

+

+ +

+ +

+ +

+ + +

+ +

+ + + + + +

+ +

+ +

+

+ + +

+ +

+ +

++

+ + +

+

+ ++ + + ++ +

+ +

+ ++ + + ++ + + + + +

+

+ + +

+ + + +

+ ++ + ++

+ + + +

++

+ +

+

+ +

+ +

++ + +

+ + +

+ +

+ + +

+

+ +

+ + + ++

+

+ +

+ +

+

+ + +

+ + +

+ ++

+ +

+ +

+

+ +

+ +

++

+ + + ++ + + + + + ++

+ +

+ ++

+ +

+ + +

+

+ + +

+ +

+ ++

++

+ + +

+ +

+

+

+

+ ++ +

+

++ + + +

++++ + + ++

++ +

+ +

+ +

+

+ ++ + +

+ +

+ +

+ +

+

+

+ + +

+

+ + ++

+

+ + + +

+

+ + + +

+ +

+ +

+ ++

+ + ++

+ +

+ + +++ ++++

+

+ ++ +

+

+ + + +

+ +

+ +

+ + + + +

+ +

++ +

+

+ + + + + + +

+

+

+ +

+

+ ++

+ +

+ +

+ +

+ + +

+

+

+ +

+ +

+

+ + +

++ + ++ + +

+ ++

+ +

+ + +

+

+ +

+ ++ +

+ ++

++ + +

+ + +

+ +

+

+ + +

+ + + +

+ + + + + + ++ +

+ + + +++ + + ++

+ +

+ +

++

++ + +

+ ++ + +

++ ++++ + + +

+

+ + + + +

+ + ++

+

+ +

+ + +

+

+

+ +

+ ++

++

+ +

+ + + + +

+ + +

+

+

+ +

+ + ++ ++

+ + ++ +

+

+ + + +

+

+

+++ + +

+

+ ++

+ +

+ +

+ +

++ +

+ +

++ + + +

+ + +

+ +

+ ++ +

+

+ + +

+ ++ +

+

+ + + +

+

++ ++++ + + +

+

+ +

+ + ++ + + + +

+ + ++ + +

+

+ +

+ + + +++ + +

+ ++ + ++ + +

+

+ +

+

+ + ++ +

+

+ + +

+ + + + +

+ + ++

+

+ + +

+ +

+ +

+ ++

+ +

+ +

+ + + +

+

+

+ + + +

+

+ + +

+

+ +

++

+ +

+ +

+ +

+ +

+

+ + + ++ + + +

++ + +

+

+ +

+ +

+

+ +

++

+ +

+ +

+ + + +

+ + +

+ + + +

+ + +

+ +

+ + + +

+ + +

+ +

+ + + + +

+++

+

+

+ +

+

+

+ + ++

+

+ ++

+

+

+ +

+ + +

+ +

++ ++

+

+ + +

+ + + +

+ +

+ + ++

+ + ++ +

+ ++ +

+

+ +

+

+ +

+

+ +

+ + +

+ +

+

+

+ + ++

+ + +

++ +

+ +

+ +

+ +

+

+ ++

+ + +

+

+ + ++

+ + ++

+

+ +

+

+ + +

+ + +

+ + + + +

+ ++ + +

+ +

+

+ + +

+

+ + +++ + ++++ ++ + +

++ +

+ +

+ +

+ ++ ++ ++ + +

+

+ +

+ + ++

+ +

+ + + +

+ + + + + +

+ + + + +

+ ++ + + ++

+ + +

+ +

+ ++

+ +

+ + +

+

+ + +

+ +

+

+

+ +

++ + + +++ + +

+ +

+ + +

+

+ +

+ +

+ + + ++

+ + + +

+ + +

+ +

+ +

+

+ + + + ++ + +

++ + ++ + +

+

+ + +

++ +

+ +

+ + +

+ + +

+ + +

+ +

+ ++

+

++ + ++ + + +

+ +

+ ++ +

+ + +

+ +

+ +

+ +

+ + +

+ + +

+ + +

+ +

+ + + + +

+ +

+

+

+ +

+

+ +

+ + + + +

+ + + +

+

+ ++

+ + +

+ + +

+ + +

+

+ +

+ + +

+ + + +

+ + +

+

+ + +

+ ++ + + +

+ + ++ ++

+

+ + +

+ + +

++

+

+ +

+ +

+ + +++

+ +

+ ++

+ +

+ +

+ +

+ + ++

+ +

+ +

+ + + +

+

+ + + + +++++ + +

++ +

+ +

+ +

+ + +

+

+

+ +

++ + +

++ + ++ +

+ +

+

+ ++

+

+ +

+ + +

+

++ + ++ + + +

+ + +

+ + ++ ++ + +

+

+

+ +

+ + +

+ +

+

+ +

+ + ++

+ +

+ + + +

+ ++

+ ++ ++ ++

+ + +

+

+

+ +

+ + +

+

+ + + ++

+

+ + +

+

+

+

+ + +

+ + +

+

+ + +

++

+ + +

+ +

+

+ +

+ +

+ +

+ +

+

+ +

+ ++

+

+ ++ +

+

+ ++ +

+

+ + + +

+ + + +

+

+ + +

+ +++

+ ++ + +

+

+ + +

+ + + ++ + +

+ ++ +

+ + +

++ + +

+ + + +

+ + +

+

+ +

+

+ +

+ +

+

+ +

++ + + + ++

+ + + +++

+ + ++

+

+ +

+ + +

+ +

+ +

+ +

+ +

+ +

+++

+

+ + + +

+ + +

+

+ + +

+

++ ++ +

+ ++ + + + +

+

+ +

+

+ +

+ +

+ + +

+ +

+

+ + +

+ +

+ ++ +

+ +

+ ++

+ + +

+

+ + +

+

+ + +

+ + +

+ + ++ + +

+

+ + + +

+ +

+ +

+ + +

+

+ + +

+

+ + ++

+ +

+ + +

+

+ +

+

+ +

+ +

+ + +

++

+ +

+ +

+ +

+

+

+ + +

+

+

+ +

+

+

+

+ + + +

+ +++

+ +

+ +

+ +

+

+

+

+

+ + +

+ + +

++

+ +

+ +

+ +

+ + +

+

+ ++

+ + + + ++

+

+

+ +

+ + +

+

+ +

+

+

+ +

+

+

+ + +

+ +

+

++

+ + +

+ + +

++ +

+ + + +

+

+ +++ +

+ + + +

+

+ + +

+

+ + +++

+ +

+++

+

+ +

+ + +

+ + +

+ + +

+ +

+ + +

+

+ + +

+ +

+ +

+ + +

+

+ +

+

+ + +

+ +

+ + +

+ +

+

+

+ +

+ + +

+

+ +

+

+

+ + ++

+

+ + ++ + + + +

+

++ ++ +

+

+

+ +

+ + + +

+ +

+ +

+

+ +

+

+ +

++ ++ +

+

+ + + +

+

+ +

++ + + +

+ + + +

+

++

+

+

+

+ +

+ +

+

+ +

+

+

+ + +

+ +

+ + + + + +

+ + +

+ +

+ +

+ +

+ +

+

+ +

+

+

+ +

+ +

+

-3 -2 -1 0 1 2 3

-0.08-0.040.000.04

Normal Plot

Theoretical Quantiles

Sample Quantiles

(24)

Applied Time Series Analysis

SS 2014 – Week 08

ACF of SMI Log-Returns

0 5 10 15 20 25 30

0.00.20.40.60.81.0

Lag

ACF

ACF of SMI Log-Returns

(25)

25

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

ACF of of Squared SMI Log-Returns

0 5 10 15 20 25 30

0.00.20.40.60.81.0

Lag

ACF

ACF of Squared Log-Returns

(26)

Applied Time Series Analysis

SS 2014 – Week 08

The ARCH / GARCH Model

See blackboard...

(27)

27

Marcel Dettling, Zurich University of Applied Sciences

Applied Time Series Analysis

SS 2014 – Week 08

Model Choice

0 5 10 15 20 25 30

0.00.20.40.60.81.0

Lag

ACF

ACF of Squared Log-Returns

0 5 10 15 20 25 30

0.00.20.40.60.81.0

Lag

Partial ACF

PACF of Squared Log-Returns

(28)

Applied Time Series Analysis

SS 2014 – Week 08

Fitting an ARCH(2) Model

R allows for convenient fitting...

> fit <- garch(lret.smi, order = c(0,2))

> fit

Call: garch(x = lret.smi, order = c(0, 2)) Coefficient(s):

a0 a1 a2

6.568e-05 1.309e-01 1.074e-01

Referenzen

ÄHNLICHE DOKUMENTE

 The remainder term is usually a stationary time series, thus it would not be surprising if the regression model features correlated errors... Applied Time

Generated are 10‘000 1-step forecasts on a time series that was generated from an AR(1) process with. The series length

1) Perform seasonal differencing on the data. The lag s is determined by the periodicity of the data, for the order, in most cases D  1 is sufficient. 2) Do a time series

In the absence of a seasonal effect, the trend of a non-stationary time series can be determined by applying any additive, linear filter.. Applied Time

Our next goal is to estimate the autocorrelation function (acf) from a realization of weakly stationary time series.. Applied Time Series Analysis. SS 2013 –

Instead of fitting an ARIMA(1,1,2) to the logged oil series, we can also take the differenced log-oil series and fit an ARMA(1,2) to

Idea: Determine the parameters such that, given the observed time series x 1 ,…,x n , the resulting model is the most.

Whereas for AR(p) models, the current observation of a time series is written as a linear combination of its own past, MA(q) models can be seen as an extension of the „pure“ model..