Beruflich Dokumente
Kultur Dokumente
Version 1.1
This document is released under the Creative Commons Attribution-Noncommercial 2.5 India
license.
Matthieu Stigler ()
Stationary models
1 / 65
Lectures list
1
Stationarity
Seasonality
Non-stationarity
Non-linearities
Multivariate models
10
11
Matthieu Stigler ()
Stationary models
2 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
3 / 65
Recall: auto-covariance
Definition (autocovariance)
Cov(Xt , Xtk ) k (t) E [(Xt )(Xtk )]
Definition (Autocorrelation)
Corr(Xt , Xtk ) k (t)
Cov(Xt ,Xtk )
Var(Xt )
Proposition
Corr(Xt , Xt0 ) = Var(Xt )
Corr(Xt , Xtj ) = j depend on the lage: plot its values at each lag.
Matthieu Stigler ()
Stationary models
4 / 65
Recall: stationarity
Definition
A process is said to be covariance-stationary, or weakly stationary, if
its first and second moments are time invariant.
E(Yt ) = E[Yt1 ] =
Var(Yt ) = 0 <
Cov(Yt , Ytk ) = k
Matthieu Stigler ()
Stationary models
t
t
t, k
5 / 65
X
c
i ti
+
Yt =
1
i=0
c
1
Var(Xt ) =
2
12
j
2
12
= j
Cov(Xt , Xtj ) =
Corr(Xt , Xtj )
Matthieu Stigler ()
Stationary models
6 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
7 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
8 / 65
Autocorrelation function
Matthieu Stigler ()
Stationary models
9 / 65
0.0
6
10 12 14
Lag k
Lag k
= 0.9
=1
10 12 14
0.4
0.0
0.0
0.4
0.8
0.8
0.4
0.4
0.0
0.8
= 0.5
0.8
=0
10 12 14
Lag k
Matthieu Stigler ()
10 12 14
Lag k
Stationary models
10 / 65
Matthieu Stigler ()
t iid(0, 2 )
Stationary models
11 / 65
phi=0.7
ar
3
2 1
ar
phi=0.2
40
60
80
100
40
60
80
Time
= 0.2
= 0.7
100
0.5
1.0
0.0
0.5
0.0
1.0
20
Time
1.0
20
1.0
10 12 14
Lag k
Matthieu Stigler ()
10 12 14
Lag k
Stationary models
12 / 65
Definition (AR(p))
yt = c + 1 yt1 + 2 yt2 + . . . + p ytp + t
Expectation?
Variance?
Auto-covariance?
Stationary conditions?
Matthieu Stigler ()
Stationary models
13 / 65
Lag operator
Proposition
See that: L2 Xt = Xt2
Proposition (Generalisation)
Lk Xt = Xtk
Matthieu Stigler ()
Stationary models
14 / 65
Lag polynomial
We can thus rewrite:
Example (AR(2))
Xt = c + 1 Xt1 + 2 Xt2 + t
(1 1 L 2 L2 )Xt = c + t
Example (AR(2))
(L)Xt = c + t
Matthieu Stigler ()
Stationary models
15 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
16 / 65
Proposition
The AR(p) process is stable if the roots of the lag polynomial lie outside
the unit circle.
Example (AR(1))
The AR(1): Xt = Xt1 + t
can be written as: (1 L)Xt = t
Solving it gives: 1 x = 0 x =
And finally: | 1 | > 1 || < 1
Matthieu Stigler ()
Stationary models
17 / 65
Proof.
1
Matthieu Stigler ()
Stationary models
18 / 65
Proof.
The AR(p):
yt = 1 yt1 + 2 yt2 + . . . + p ytp + t
can be recast as the AR(1) model:
t = F t1 + t
yt
t
yt1
1 2 3 . . . p1 p
yt1 1 0 0 . . .
0
0 yt2 0
yt2 0 1 0 . . .
0
0
yt3 + 0
=
.. ..
..
..
..
.. .. ..
. .
.
. ...
.
. . .
0
ytp
0 0 0 ...
1
0
ytp+1
yt
= c + 1 yt1 + 2 yt2 + . . . + p ytp + t
y
= yt1
t1
...
y
tp+1 = ytp+1
Matthieu Stigler ()
Stationary models
19 / 65
Proof.
Starting from the augmented AR(1) notation:
t = F t1 + t
Similarly as in the simple case, we can write the AR model recursively:
t = F t 0 + t + F t1 + F 2 t2 + . . . + F t1 1 + F t 0
Remember the eigenvalue decomposition: F
and the propriety that: F j = T j T 1
with
j
1 0 . . .
0 j . . .
2
j = .
..
..
. ...
0
= T T 1
0
0
..
.
. . . j3
Stationary models
20 / 65
Proof.
So the condition on F is that all from |F I | = 0 are < 1.
One can show that the eigenvalues of F are:
Proposition
p 1 p1 2 p2 . . . p1 p = 0
But the are the reciprocal of the values z that solve the characteristic
polynomial of the AR(p):
(1 1 z 2 z 2 . . . p z p ) = 0
So the roots of the polynomial should be > 1, or, with complex values,
outside the unit circle.
Matthieu Stigler ()
Stationary models
21 / 65
Stationarity conditions
1 + 2 < 1
1 2 < 1
|2 | < 1
Matthieu Stigler ()
Stationary models
22 / 65
Example
Consider the AR(2) model:
Yt = 0.8Yt1 + 0.09Yt2 + t
Its AR(1) representation is:
yt
0.8 0.09 yt1
=
+ t
yt1
1
0
yt2
0
Hence
its eigenvalues
are taken from:
0.8 0.09
= 2 0.8 0.09 = 0
1
0
And the eigenvalues are smaller than one:
> Re(polyroot(c(-0.09, -0.8, 1)))
[1] -0.1
0.9
Matthieu Stigler ()
Stationary models
23 / 65
Example
Yt = 0.8Yt1 + 0.09Yt2 + t
Its lag polynomial representation is: (1 0.8L 0.09L2 )Xt = t
Its characteristic polynomial is hence: (1 0.8x 0.09x 2 ) = 0
whose solutions lie outside the unit circle:
> Re(polyroot(c(1, -0.8, -0.09)))
[1]
1.111111 -10.000000
[1] TRUE
Matthieu Stigler ()
Stationary models
24 / 65
Proposition
An AR(p) process with k unit roots (or eigenvalues) is integrated of order
k.
Example
Take the random walk: Xt = Xt1 + t
Its polynomial is (1-L), and the roots is 1 x = 0 x = 1
The eigenvalue of the trivial AR(1) is 1 = 0 = 1
So the random walk is integrated of order 1 (or difference stationary).
Matthieu Stigler ()
Stationary models
25 / 65
Integrated process
Take an AR(p):
yt = 1 yt1 + 2 yt2 + . . . + p ytp + t
With the lag polynomial:
(L)Xt = t
If one of its p (not necessarily distinct) eigenvalues is equal to 1, it can be
rewritten:
(1 L)0 (L)Xt = t
Equivalently:
0 (L)Xt = t
Matthieu Stigler ()
Stationary models
26 / 65
c
11 2 ...p
Var(Xt ) = 1 1 + 2 2 + . . . + p p + 2
Cov(Xt , Xtj ) = 1 j1 + 2 j2 + . . . + p jp
Note
that j Cov(Xt , Xtj ) so we can rewrite both last equations as:
(
0 = 1 1 + 2 2 + . . . + p p + 2
j = 1 j1 + 2 j2 + . . . + p jp
They are known under the name of Yule-Walker equations.
Matthieu Stigler ()
Stationary models
27 / 65
Yule-Walker equations
Dividing by 0 gives:
(
0 = 1 1 + 2 2 + . . . + p p + 2
j = 1 j1 + 2 j2 + . . . + p jp
Example (AR(1))
We saw that:
Var(Xt ) =
2
12
j
2
12
= j
Cov(Xt , Xtj ) =
Corr(Xt , Xtj )
Stationary models
28 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
29 / 65
Matthieu Stigler ()
Stationary models
30 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
31 / 65
Two significations!
regression model
Smoothing technique!
Matthieu Stigler ()
Stationary models
32 / 65
MA(1)
Definition (MA(1))
Yt = c + t + t1
E(Yt ) = c
Var(Yt ) = (1 + 2 ) 2
(
2
Cov(Xt , Xtj ) =
0
(
Corr(Xt , Xtj ) =
if j = 1
if j > 1
(1+2 )
if j = 1
if j > 1
Proposition
A MA(1) is stationnary for every
Matthieu Stigler ()
Stationary models
33 / 65
= 0.5
0 2 4 6 8
=2
20
40
60
80
100
20
40
60
Time
Time
= 0.5
= 2
80
100
80
100
1 2 3
20
40
60
80
100
20
Time
Matthieu Stigler ()
40
60
Time
Stationary models
34 / 65
0.0
6
10
Lag k
Lag k
= 0.5
= 3
10
10
0.5
0.0
1.0
1.0
0.0
0.5
1.0
1.0
0.4
0.4
0.0
0.8
=3
0.8
= 0.5
10
Lag k
Matthieu Stigler ()
6
Lag k
Stationary models
35 / 65
MA(q)
The MA(q) is given by:
Yt = c + t + 1 t1 + 2 t2 + . . . + 1 tq
E(Yt ) = c
Var(Yt ) = (1 + 12 + 22 + . . . + q2 ) 2
Cov(X
t , Xtj ) =
(
2
(j + j+1 1 + j+2 2 + . . . + q q1 )
0
(
if j = 1
(1+2 )
Corr(Xt , Xtj ) =
0
if j > 1
if j = 1
if j > 1
Proposition
A MA(q) is stationary for every sequence {1 , 2 , . . . , q }
Matthieu Stigler ()
Stationary models
36 / 65
= c( 0.5,, 1.5)
0.5
1.0
2
10
10
0.5
0.0
1.0
0.0
0.5
1.0
Lag k
1.0
Lag k
1.0
0.0
0.4
0.0
0.8
1.0
= c(0.5,, 1.5)
10
Lag k
Matthieu Stigler ()
10
Lag k
Stationary models
37 / 65
The MA()
Take now the MA():
Yt = t + 1 t1 + 2 t2 + . . . + =
j tj
j=0
i=0 |i |
<0
Proposition
The MA() is stationary if the coefficients are absolute summable.
Matthieu Stigler ()
Stationary models
38 / 65
Back to AR(p)
Recall:
Proposition
If the characteristic polynomial of a AR(p) has roots =1, it is not
stationary.
See that:
(1 1 yt1 2 yt2 . . . p ytp )yt =
(1 1 L)(1 2 L) . . . (1 p L)yt = t
It has a MA() representation if: 1 6= 1:
yt = (11 L)(112 L)...(1p L) t
Furthermore, if the i (the eigenvalues of the augmented AR(1)) are
smaller than 1, we can write it:
yt =
i t
i=0
Matthieu Stigler ()
Stationary models
39 / 65
Estimation of a MA(1)
)
t1
t=1 t
This recquires numerical optimization and works only if || < 1.
Matthieu Stigler ()
Stationary models
40 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
41 / 65
ARMA models
The ARMA model is a composite of AR and MA:
Definition (ARMA(p,q))
Xt = c+1 Xt1 +2 Xt2 +. . .+p Xtp +t1 +1 t1 +2 t2 +. . .+tq
It can be rewritten properly as:
(L)Yt = c + (L)t
Theorem
The ARMA(p,q) model is stationary provided the roots of the (L)
polynomial lie outside the unit circle.
So only the AR part is involved!
Matthieu Stigler ()
Stationary models
42 / 65
Proposition
After q lags, the autocorrelation function follows the pattern of the AR
component.
Remember: this is then given by the Yule-Walker equations.
Matthieu Stigler ()
Stationary models
43 / 65
phi(1)=0.5, theta(1)=0.5
0.5
1.0
0.0
0.4
0.0
0.8
1.0
phi(1)=0.5, theta(1)=0.5
10
Lag k
10
Lag k
1.0
0.5
0.0
1.0
0.0
1.0
0.5
1.0
10
Lag k
Matthieu Stigler ()
10
Lag k
Stationary models
44 / 65
ARIMA(p,d,q)
Definition (ARIMA(p,d,q))
ARIMA(p,d,q): (L)d Yt = (L)t
Matthieu Stigler ()
Stationary models
45 / 65
Matthieu Stigler ()
Stationary models
46 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
47 / 65
Estimation
Matthieu Stigler ()
Stationary models
48 / 65
Step 1
Transformations:
Log
Square root
Differenciation
(
Box-Cox transformation:
()
Yt
Yt 1
log(Y t)
for 6= 0
for = 0
Is log legitimate?
Process is: yt e t Then zt = log(yt ) = t and remove trend
Process is yt = yt1 + t Then (by log(1 + x)
= x)
log(yt ) =
Matthieu Stigler ()
yt yt1
yt
Stationary models
49 / 65
Step 2
Matthieu Stigler ()
Stationary models
50 / 65
Step 2: identification
Definition (IC)
AIC (p) = n log
2 + 2p
BIC (p) = n log
2 + p log n
Matthieu Stigler ()
Stationary models
51 / 65
Step 3: estimation
Matthieu Stigler ()
Stationary models
52 / 65
Autocorrelation
Heteroscedasticity
Normality
Matthieu Stigler ()
Stationary models
53 / 65
80
60
40
20
CPI
100
120
140
CPI
1985
1990
1995
2000
2005
Time
Matthieu Stigler ()
Stationary models
54 / 65
diff(CPI)
20
1
2 1
diff(CPI)
100
60
CPI
140
original
1995
2005
1985
1995
Time
Time
log(CPI)
diff(log(CPI))
2005
0.02
0.02
0.00
diff(log(CPI))
4.0
3.5
3.0
log(CPI)
4.5
5.0
1985
1985
1995
2005
1985
Time
Matthieu Stigler ()
1995
2005
Time
Stationary models
55 / 65
detrend
20 60
CPI
120
linear trend
1985
1990
1995
2000
2005
1985
1990
Time
1995
2000
2005
2000
2005
2000
2005
Time
1985
1990
1995
2000
6
2
2
CPI
20 60
120
CPI smo$y
Smooth trend
2005
1985
1990
Time
1995
Time
10
5
0
detrend2
20 60
CPI
120
Quadratic trend
1985
1990
1995
Time
Matthieu Stigler ()
2000
2005
1985
1990
Stationary models
1995
Time
56 / 65
1
3
diff2
Diff2
1985
1990
1995
2000
2005
2000
2005
Time
0.00
0.03
diff2log
Diff2 of log
1985
1990
1995
Time
Matthieu Stigler ()
Stationary models
57 / 65
0.3
0.1
Partial ACF
0.03 0.01
CPI2
0.01
0.1
Series CPI2
1985
1995
2005
0.5
Time
1.0
1.5
2.0
Lag
0.0
0.2
ACF
0.2
Series CPI2
0.5
1.0
1.5
2.0
Lag
Matthieu Stigler ()
Stationary models
58 / 65
> library(forecast)
Series: CPI2
ARIMA(2,0,1)(2,0,2)[12] with zero mean
Coefficients:
ar1
ar2
0.2953 -0.2658
s.e. 0.0630
0.0578
ma1
-0.9011
0.0304
sar1
0.6021
0.1067
sar2
0.3516
0.1051
sma1
-0.5400
0.1286
sma2
-0.2850
0.1212
Matthieu Stigler ()
Stationary models
59 / 65
1985
1995
2005
0.00
0.10
Partial ACF
0.00
0.02
res
0.02
0.10
Series res
0.5
Time
1.0
1.5
2.0
Lag
0.05
0.15
ACF
0.05
Series res
0.5
1.0
1.5
2.0
Lag
Matthieu Stigler ()
Stationary models
60 / 65
> Box.test(res)
Box-Pierce test
data: res
X-squared = 0.0736, df = 1, p-value = 0.7862
Matthieu Stigler ()
Stationary models
61 / 65
0.01
0.02
Sample Quantiles
Normal QQ Plot
Theoretical Quantiles
40
0
Density
80
density.default(x = res)
0.02
0.01
0.00
0.01
0.02
Stationary models
62 / 65
Outline
1
Last Lecture
AR(p) models
Autocorrelation of AR(1)
Stationarity Conditions
Estimation
MA models
ARMA(p,q)
The Box-Jenkins approach
Forecasting
Matthieu Stigler ()
Stationary models
63 / 65
Notation (Forecast)
yt+j Et (yt+j ) = E(yt+j |yt , yt1 , . . . , t , t1 , . . .) is the conditional
expectation of yt+j given the information available at t.
1
H
PH
2
i=1 ei
Matthieu Stigler ()
Stationary models
64 / 65
R implementation
Matthieu Stigler ()
Stationary models
65 / 65