Lecture 02 20190212
Lecture 02 20190212
Lecture 02 20190212
8
6
1
6
5
x1
x2
x3
0
4
4
−1
2
−2
8
6 AR(1), mean = 5
x3
4
2
Time
AR(1), mean = 5
8
6
x3
4
2
Time
We can see that the fluctuations are indeed around a constant mean and
the variance does not appear to change throughout the period.
Some non-stationary time series examples:
I The first time series is not stationary because its mean is not
constant: EYt = t - depends on t;
I The second time series is not stationary because its variance is not
constant: Var (Yt ) = t 2 · σ 2 - depends on t.
However, EYt = 0 · t = 0 is constant;
I The third time series is not stationary because even though
Pt
EYt = j=1 (0.5 + (−0.5)) = 0, the variance
Var (Yt ) = E(Yt2 ) − (E(Yt ))2 = E(Yt2 ) = t where:
Pt
E(Yt2 ) = E(Zj2 ) + 2 E(Zj Zk ) = t · (0.5 · 1 + 0.5 · (−1)2 ) = t
P
j=1 j6=k
The sample data graphs are provided below:
non stationary in mean non stationary in variance no clear tendency
50
4
100
3
40
2
50
30
1
ns1
ns2
ns3
0
20
−1
10
−2
−50
−3
0
0 10 20 30 40 50 0 10 20 30 40 50 0 10 20 30 40 50
How can we know which of the previous three stationary graphs are not
WN? Two functions help us determine this:
If all the bars (except the 0th in the ACF) are within the blue band - the
stationary process is WN.
WN MA(3) AR(1)
1.0
0.8
0.8
0.6
ACF
ACF
ACF
0.4
0.4
0.2
0.0
0.0
−0.2
0 5 10 15 20 0 5 10 15 20 0 5 10 15 20 25
WN MA(3) AR(1)
0.10
0.6
0.3
Partial ACF
Partial ACF
Partial ACF
0.4
0.00
0.1
0.2
−0.10
0.0
−0.1
5 10 15 20 5 10 15 20 0 5 10 15 20 25
Series x0 Series x0
0.3
1.0
0.8
0.2
0.6
0.1
Partial ACF
0.4
ACF
0.0
0.2
−0.1
0.0
−0.2
−0.2
0 5 10 15 5 10 15
Lag Lag
Covariance-Stationary Time Series
I In cross-sectional data different observations were assumed to be
uncorrelated;
I In time series we require that there be some dynamics, some
persistence, some way in which the present is linked to the past and
the future - to the present. Having historical data then would allow
us to forecast the future.
1.96
∆=0± √
T
1−Q
I Compute α = , where Q is the confidence level;
2
I To express the critical value as a z − score, find the z1−α value.
I E(t ) = 0;
I Var (t ) = σ 2 < ∞;
I γ(t, τ ) = E(t − Et )(t−τ − Et−τ ) = E(t t−τ ), where:
(
0, 6 0
if τ =
E(t t−τ ) =
σ 2 , if τ = 0
Example on how to check if a process is stationary.
Let us check if Yt = t + β1 t−1 , where t ∼ WN(0, σ 2 ) is stationary:
1. EYt = E(t + β1 t−1 ) = 0 + β1 · 0 = 0;
2. Var (Yr ) = Var (t + β1 t−1 ) = σ 2 + β12 σ 2 = σ 2 (1 + β1 );
3. The autocovariance for τ > 0:
γ(t, τ ) = E(Yt Yt−τ ) = E(t + β1 t−1 )(t−τ + β1 t−τ −1 )
= Et t−τ + β1 Et t−τ −1 + β1 Et−1 t−τ + β12 Et−1 t−τ −1
(
β1 σ 2 , if τ = 1
= β1 Et−1 t−τ =
0, if τ > 1
P∞
where β0 = 1 and j=0 βj2 < ∞. On the other hand, any process of the
above form is stationary.
I If β1 = β2 = ... = 0 - this corresponds to a WN process. This shows
once again that WN is a stationary process.
I If βk = φk , then since 1 + φ + φ2 + ... = 1/(1 − φ) < ∞ we have
that if |φ| < 1, then the process Yt = + φt−1 + φ2 t−2 + ... is a
stationary process.
In Wold’s theorem, we assumed a zero mean, though this is not as
restrictive as it may seem. Whenever you see Yt , analyse the process
Yt − µ, so that the process is expressed in deviations from its mean. The
deviation from the mean has a zero mean by construction. So, there is
not generality loss, when analyzing zero-mean processes.
Wold’s representation theorem points to the importance of models with
infinite distributed (weighted) lags. Although infinite distributed lag
models are not of immediate practical use since they contain infinite
parameters, although this may not always be the case. From the previous
slide, βk = φk of the infinite polynomial B(L) - is only one parameter.
Estimation and Inference for the Mean, ACF and PACF
E (Yt − µ) (Yt−τ − µ)
ρ(τ ) = 2
E (Yt − µ)
1 PT
t=1 Yt − Ȳ Yt−τ − Ȳ
ρ̂(τ ) = T
1 PT 2
Yt − Ȳ
T t=1
This estimator is called the sample autocorrelation function (sample
ACF).
It is often of interest to assess whether a series is reasonably
approximated as white noise, i.e. whether all of its autocorrelations are
zero in population.
If a series is white noise, then the sample autocorrelations ρ̂(τ ), √
τ = 1, ..., K in large samples are independent and have the N (0, 1/ T )
distribution.
Thus, if the series is WN, ~95%
√ of the sample autocorrelations should
fall in the interval of ±1.96/ T .
Exactly the same holds for both sample ACF and sample PACF. We
typically plot the sample ACF and sample PACF along with their error
bands.
The aforementioned error bands provide 95% confidence bounds for only
the sample autocorrelation taken one at a time.
We are often interested in whether a series is white noise, i.e. whether all
its autocorrelations are jointly zero. Because of the sample size, we can
only take a finite number of autocorrelations. We want to test:
suppressPackageStartupMessages({require("forecast")})
txt1 <- "http://uosis.mif.vu.lt/~rlapinskas/(data%20R&GRETL/"
txt2 <- "caemp.txt"
caemp <- read.csv(url(paste0(txt1, txt2)),
header = TRUE, as.is = TRUE)
caemp <- ts(caemp, start = c(1960, 1), freq = 4)
tsdisplay(caemp)
caemp
105
95
90
85
1.0
0.8
0.8
0.6
0.6
0.4
0.4
PACF
ACF
0.2
0.2
−0.2 0.0
−0.2 0.0
5 10 15 20 5 10 15 20
Lag Lag
I The sample ACF are large and display a slow one-sided decay;
I The sample PACF are large at first, but are statistically negligible
beyond displacement τ = 2.
We shall once again test the WN hypothesis, this time using the
Ljung-Box test statistic.
Box.test(caemp, lag = 1, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: caemp
## X-squared = 127.73, df = 1, p-value < 2.2e-16
##
## Box-Ljung test
##
## data: caemp
## X-squared = 240.45, df = 2, p-value < 2.2e-16
t = (1 − θL + θ2 L2 − θ3 L3 + ...)Yt
= Yt − θYt−1 + θ2 Yt−2 − θ3 Yt−3 + ...
Partial ACF
0.6
ACF
0.4
0.2
0.0
−0.2
0 1 2 3 4 5 1 2 3 4 5
Lag Lag
0.1
0.8
0.0
Partial ACF
0.4
ACF
−0.2
0.0
−0.4
−0.4
0 1 2 3 4 5 1 2 3 4 5
Lag Lag
The MA(q) Process
We will now consider a general finite-order moving average process of
order q, MA(q):
where
Θ(L) = 1 + θ1 L + ... + θq Lq
is the qth-order lag polynomial. The MA(q) process is a generalization of
the MA(1) process. Compared to MA(1), MA(q) can capture richer
dynamic patterns which can be used for improved forecasting.
The properties of an MA(q) processes are parallel to those of an MA(1)
process in all respects:
0.4
0.0
0 2 4 6 8
Lag
0.2
0.0
−0.4
2 4 6 8
Lag
Yt = φYt−1 + t , t ∼ WN(0, σ 2 )
or:
1
(1 − φL)Yt = t ⇒ Yt = t
1 − φL
Or, alternatively: when |φ| < 1 - the process is stationary, i.e. EYt = m,
therefore EYt = φEYt−1 + Et ⇒ m = φm + 0 ⇒ m = 0.
This allows us to easily estimate the mean of the generalized AR(1)
process: if Yt = α + φYt−1 + t , then m = α/(1 − φ).
The correlogram (ACF & PACF) of AR(1) is in a sense symmetric to that
of MA(1):
0.4
0.0
0 1 2 3 4 5
Lag
0.4
0.0
1 2 3 4 5
Lag
The AR(p) Process
The general pth order autoregressive process, AR(p) is:
Yt = φ1 Yt−1 + φ2 Yt−2 + ... + φp Yt−p + t , t ∼ WN(0, σ 2 )
In lag operator form, we write:
Φ(L)Yt = (1 − φ1 L − φ2 L2 − ... − φp Lp )Yt = t
Similar to the AR(1) case, the AR(p) process is covariance stationary
if and only if all the roots zi of the autoregressive lag operator polynomial
Φ(z) are outside the complex unit circle:
1 − φ1 z − φ2 z 2 − ... − φp z p = 0 ⇒ |zi | > 1
So:
1
Yt = t
Φ(L)
I The ACF for the general AR(p) process decays gradually when the
lag increases;
I The PACF for the general AR(p) process has a sharp cutoff at
displacement p.
An example on how the sample ACF and PACF would look like of AR(2)
process Yt = 1.5Yt−1 − 0.9Yt−2 + T :
0.5
Partial ACF
0.5
ACF
−0.5
−0.5
0 5 10 15 20 5 10 15 20
Lag Lag
Because the roots are complex, the ACF oscillates and because the roots
are close to the unit circle, the oscillation damps slowly.
Stationarity and Invertibility
The AR(p) is a generalization of the AR(1) strategy for approximating
the Wold representation. The moving-average representation associated
with the stationary AR(p) process:
∞
1 1 X
Yt = t where = ψj Lj , ψ0 = 1
Φ(L) Φ(L) j=0
∞
X
Yt = ψj t−j
j=0
∞
1 1 X
t = Yt , where = πj Lj , π0 = 1
Θ(L) Θ(L) j=0
∞
X ∞
X
t = πj Yt−j = Yt + πj Yt−j
j=0 j=1
or:
Φ(L)Yt = Θ(L)t
I If all the roots of Φ(L) are outside the unit circle, then the process is
stationary and has a convergent infinite moving average
representation: Yt = (Φ(L)/Θ(L)) t ;
I If all roots of Θ(L) are outside the unit circle, then the process is
invertible and can be expressed as the convergent infinite
autoregression: (Φ(L)/Θ(L)) Yt = t .
An example of an ARMA(1,1) process: Yt = 0.85Yt−1 + t + 0.5t−1 :
0.8
ARMA(1,1) with φ = 0.85, θ = 0.5,
ACF
0.4
0.0
0 5 10 15 20
Lag
0.4
0.0
−0.4
5 10 15 20
Lag
ARMA models are often both highly accurate and highly parsimonious.
In a particular situation, for example, it might take an AR(5) model to
get the same approximation accuracy as could be obtained with an
ARMA(1,1), but the AR(5) has five parameters to be estimated, whereas
the ARMA(1,1) has only two.
Yt = φ1 Yt−1 + t
γ(1) = φγ(0)