• Keine Ergebnisse gefunden

Applied Time Series Analysis

N/A
N/A
Protected

Academic year: 2022

Aktie "Applied Time Series Analysis"

Copied!
34
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Applied Time Series Analysis

FS 2012 – Week 04

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, March 12, 2012

(2)

Applied Time Series Analysis

FS 2012 – Week 04

Where are we?

For much of the rest of this course, we will deal with (weakly) stationary time series. They have the following properties:

If a time series is non-stationary, we know how to decompose into deterministic and stationary, random part.

Our forthcoming goals are:

- understanding the dependency in a stationary series - modeling this dependency and generate forecasts

[ t]

E X   ( t) 2

Var X 

( t, t h) h Cov X X  

(3)

Applied Time Series Analysis

FS 2012 – Week 04

Autocorrelation

The aim of this section is to explore the dependency structure within a time series.

Def: Autocorrelation

The autocorrelation is a dimensionless measure for the

amount of linear association between the random variables collinearity between the random variables and .

( , )

( ) ( , )

( ) ( )

t k t

t k t

t k t

Cov X X k Cor X X

Var X Var X

 

X

X

(4)

Applied Time Series Analysis

FS 2012 – Week 04

Interpretation of Autocorrelations

How to interpret autocorrelation from a practical viewpoint?

 We e.g. assume that .

 Then, the square of the correlation coefficient, i.e.

, , is the percentage of variability explained by the linear association between and its respective predecessor .

 Here in our example, accounts for roughly 49%

of the variability observed in random variable .

 From this we can also conclude that any is not a very strong association, i.e. has small effect.

( ) k 0.7

 

( )k 2 0.49

Xt 1

Xt

1

Xt

Xt

( ) k 0.4

 

(5)

Applied Time Series Analysis

FS 2012 – Week 04

Autocorrelation Estimation: lag k

How does it work?

Plug-in estimate with sample covariance

where

and

1

ˆ( ) 1 ( )( )

n k

s k s

s

k x x x x

n

 

1

1 n

t t

x x

n

ˆ( ) ( , )

ˆ ( )

ˆ(0) ( )

t t k

t

Cov X X k k

Var X

 

 

(6)

Applied Time Series Analysis

FS 2012 – Week 04

Application: Variance of the Arithmetic Mean

Practical problem: we need to estimate the mean of a realized/

observed time series. We would like to attach a standard error.

• If we estimate the mean of a time series without taking into account the dependency, the standard error will be flawed.

• This leads to misinterpretation of tests and confidence intervals and therefore needs to be corrected.

• The standard error of the mean can both be over-, but also underestimated. This depends on the ACF of the series.

For the derivation, see the blackboard…

(7)

Applied Time Series Analysis

FS 2012 – Week 04

Outlook to AR(p)-Models

Suppose that Et is an i.i.d random process with zero mean and variance . Then a random process Xt is said to be an auto- regressive process of order p if

This is similar to a multiple regression model, but Xt is regressed not on independent variables, but on past values of itself. Hence the term auto-regressive.

We use the abbreviation AR(p).

2

E

1 1

...

t t p t p t

X   X

   X

E

(8)

Applied Time Series Analysis

FS 2012 – Week 04

Partial Autocorrelation Function (PACF)

The partial autocorrelation is defined as the correlation between and , given all the values in between.

Interpretation:

• Given a time series , the partial autocorrelation of lag k, is the autocorrelation between and with the linear

dependence of through to removed.

• One can draw an analogy to regression. The ACF measu- res the „simple“ dependence between and , whereas the PACF measures that dependence in a „multiple“ fashion.

Xt k

Xt

k

k

th

Xt k Xt

1 1 1 1

( , | ,..., )

k

Cor X

t k

X

t

X

t

x

t

X

t k

x

t k

 

 

 

Xt

Xt Xt k

1

Xt Xt k 1

(9)

Applied Time Series Analysis

FS 2012 – Week 04

Facts About the PACF and Estimation

We have:

• for AR(1) models, we have ,

because

• For estimating the PACF, we utilize the fact that for any AR(p) model, we have: and for all . Thus, for finding , we fit an AR(p) model to the series for various orders p and set

1 1

2

2 1

2 2

1 1

 

 

 

2  0

2

2 1

p p

ˆp

ˆp ˆp

k 0

kp

(10)

Applied Time Series Analysis

FS 2012 – Week 04

Facts about the PACF

• Estimation of the PACF is implemented in R.

• The first PACF coefficient is equal to the first ACF coefficient.

Subsequent coefficients are not equal, but can be derived from each other.

• For a time series generated by an AR(p)-process, the

PACF coefficient is equal to the AR-coefficient. All PACF coefficients for lags are equal to 0.

• Confidence bounds also exist for the PACF.

p

th

p

th

kp

(11)

Applied Time Series Analysis

FS 2012 – Week 04

Basics of Modeling

(Time Series) Model

Data

Data

(Time Series) Model

Simulation

Estimation

Inference Residual Analysis

(12)

Applied Time Series Analysis

FS 2012 – Week 04

A Simple Model: White Noise

A time series is a White Noise series if the random variables are independent and identically distributed with mean zero.

This imples that all variables have the same variance , and for all .

Thus, there are no autocorrelations either: for all . If in addition, the variables also follow a Gaussian distribution, i.e.

, the series is called Gaussian White Noise.

1 2

(W W, ,...,Wn)

1, 2,...

W W

Wt

W2

(

i

,

j

) 0

Cov W Wij

k 0

k  0

~ (0, 2 )

t W

W N

(13)

Applied Time Series Analysis

FS 2012 – Week 04

Example: Gaussian White Noise

Time

0 50 100 150 200

-2-1012

Gaussian White Noise

(14)

Applied Time Series Analysis

FS 2012 – Week 04

Example: Gaussian White Noise

0 5 10 15 20

-1.0-0.50.00.51.0

Lag

ACF

ACF of Gaussian White Noise

(15)

Applied Time Series Analysis

FS 2012 – Week 04

Time Series Modeling

There is a wealth of time series models - AR autoregressive model

- MA moving average model

- ARMA combination of AR & MA - ARIMA non-stationary ARMAs - SARIMA seasonal ARIMAs

- …

Autoregressive models are among the simplest and most intuitive time series models that exist.

(16)

Applied Time Series Analysis

FS 2012 – Week 04

Basic Idea for AR-Models

We have a time series where, resp. we model a time series such that the random variable depends on a linear combination of

the preceding ones , plus a „completely independent“

term called innovation .

p is called the order of the AR-model. We write AR(p). Note that there are some restrictions to .

1

,...,

t t p

X

X

E

t

1 1

...

t t p t p t

X   X

   X

E

E

t

Xt

(17)

Applied Time Series Analysis

FS 2012 – Week 04

AR(1)-Model

The simplest model is the AR(1)-model

where

is i.i.d with and

Under these conditions, is a white noise process, and we additionally require causality, i.e. being an innovation:

is independent of

E

t

E

t

1 1

t t t

X   X

E

[

t

] 0

E EVar E (

t

)  

E2

E

t s

,

X st

E

t

(18)

Applied Time Series Analysis

FS 2012 – Week 04

Causality

Note that causality is an important property that, despite the fact that it‘s missing in much of the literature, is necessary in the

context of AR-modeling:

is an innovation process  all are independent All are independent

E

t

E

t is an innovation

E

t

E

t

(19)

Applied Time Series Analysis

FS 2012 – Week 04

Simulated AR(1)-Series

Simulated AR(1)-Series: alpha_1=0.7

ts.sim

0 50 100 150 200

-3-2-101234

(20)

Applied Time Series Analysis

FS 2012 – Week 04

Simulated AR(1)-Series

Simulated AR(1)-Series: alpha_1=-0.7

Time

ts.sim

0 50 100 150 200

-4-3-2-10123

(21)

Applied Time Series Analysis

FS 2012 – Week 04

Simulated AR(1)-Series

Simulated AR(1)-Series: alpha_1=1

ts.sim

0 50 100 150 200

-290-285-280-275

(22)

Applied Time Series Analysis

FS 2012 – Week 04

Moments of the AR(1)-Process

Some calculations with the moments of the AR(1)-process give insight into stationarity and causality

Proof: See blackboard…

(23)

Applied Time Series Analysis

FS 2012 – Week 04

Theoretical vs. Estimated ACF

0 50 100 150 200

0.00.20.40.60.81.0

lag

ACF

True ACF of AR(1)-process with alpha_1=0.7

-0.20.20.61.0

ACF

Estimated ACF from an AR(1)-series with alpha_1=0.7

(24)

Applied Time Series Analysis

FS 2012 – Week 04

Theoretical vs. Estimated ACF

0 50 100 150 200

-0.50.00.51.0

lag

ACF

True ACF of AR(1)-process with alpha_1=-0.7

0 50 100 150 200

-0.50.00.51.0

ACF

Estimated ACF from an AR(1)-series with alpha_1=-0.7

(25)

Applied Time Series Analysis

FS 2012 – Week 04

AR(p)-Model

We here introduce the AR(p)-model

where again

is i.i.d with and

Under these conditions, is a white noise process, and we additionally require causality, i.e. being an innovation:

is independent of

E

t

E

t

[

t

] 0

E EVar E (

t

)  

E2

E

t s

,

X st E

t

1 1

...

t t p t p t

X   X

   X

E

(26)

Applied Time Series Analysis

FS 2012 – Week 04

Mean of AR(p)-Processes

As for AR(1)-processes, we also have that:

is from a stationary AR(p) =>

Thus: If we observe a time series with , it cannot be, due to the above property, generated by an AR(p)-

process

But: In practice, we can always de-“mean“ (i.e. center) a stationary series and fit an AR(p) model to it.

[

t

] 0 E X  ( X

t t T

)

[

t

] 0

E X   

(27)

Applied Time Series Analysis

FS 2012 – Week 04

Yule-Walker-Equations

On the blackboard…

We observe that there exists a linear equation system built up from the AR(p)-coefficients and the ACF-coefficients of up to lag p.

These are called Yule-Walker-Equations.

We can use these equations for fitting an AR(p)-model:

1) Estimate the ACF from a time series

2) Plug-in the estimates into the Yule-Walker-Equations 3) The solution are the AR(p)-coefficients

(28)

Applied Time Series Analysis

FS 2012 – Week 04

Stationarity of AR(p)-Processes

We require:

1)

2) Conditions on

All (complex) roots of the characteristic polynom

need to lie outside of the unit circle. This can be checked with R-function polyroot()

[

t

] 0

E X   

( 

1

,..., 

p

)

2

1 2

1   z   z  

p

z

p

 0

(29)

Applied Time Series Analysis

FS 2012 – Week 04

A Non-Stationary AR(2)-Process

is not stationary…

1 2

1 1

2 2

t t t t

XX

X

E

Non-Stationary AR(2)

-10-505

(30)

Applied Time Series Analysis

FS 2012 – Week 04

Fitting AR(p)-Models

This involves 3 crucial steps:

1) Is an AR(p) suitable, and what is p?

- will be based on ACF/PACF-Analysis 2) Estimation of the AR(p)-coefficients

- Regression approach - Yule-Walker-Equations

- and more (MLE, Burg-Algorithm) 3) Residual Analysis

- to be discussed

(31)

Applied Time Series Analysis

FS 2012 – Week 04

AR-Modelling

1 2 3 Identification Parameter Model

of the Order p Estimation Diagnostics

- ACF/PACF - Regression - Residual Analysis

- AIC/BIC - Yule-Walker - Simulation

- MLE - Burg

(32)

Applied Time Series Analysis

FS 2012 – Week 04

Is an AR(p) suitable, and what is p?

- For all AR(p)-models, the ACF decays exponentially quickly, or is an exponentially damped sinusoid.

- For all AR(p)-models, the PACF is equal to zero for all lags k>p.

If what we observe is fundamentally different from the above, it is unlikely that the series was generated from an AR(p)-process. We thus need other models, maybe more sophisticated ones.

Remember that the sample ACF has a few peculiarities and is tricky to interpret!!!

(33)

Applied Time Series Analysis

FS 2012 – Week 04

Model Order for sqrt(purses)

Time

series

1968 1969 1970 1971 1972 1973

23456-0.20.41.0Auto-Korr. -0.20.2part. Autokorr

(34)

Applied Time Series Analysis

FS 2012 – Week 04

Model Order for log(lynx)

Time

series

1820 1840 1860 1880 1900 1920

456789-0.50.5Auto-Korr.

0 5 10 15 20

-0.50.5part. Autokorr

1 5 10 15 20

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

See blackboard for an example how the state space formulation of an AR(2) is set up ... Applied Time Series Analysis. FS 2014 –

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 –

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..