Professional Documents
Culture Documents
Daniel Buncic
Institute of Mathematics & Statistics
University of St. Gallen
Switzerland
Homepage
www.danielbuncic.com
University of St. Gallen
Outline/Table of Contents
Outline
Introduction
Overview
Descriptive Analysis
Probabilistic Approach
Examples of Time Series
Objectives of Time Series Analysis
Basic Concepts
Some Definitions
Examples of Time Seriess
General Approach to Time Series Modeling
Stationary Models
Autocovariance and Autocorrelation
Some Model Based Examples
Sample Autocovariance and Autocorrelation
Estimation and Elimination of Both Trend and
Seasonality
Lag (or Backshift) Operator
Exercises
2/65
Introduction
Overview
Overview
A time series is a set of observations xt , each one being recorded at a specific time t:
discrete-time time series, when the set T0 of times at which observations are
made is a discrete set;
Of particular interest are discrete-time time series with observations recorded at fixed
time intervals. Time-distance between observations is called frequency.
Typical frequencies used in practice: daily, monthly, quarterly, . . .
3/65
Introduction
Descriptive Analysis
Descriptive Analysis
Plot a two-dimensional graph of recording times t (X-axis) vs. observations
yt , t = 1, . . . , T (Y -axis).
Generally, some smoothing techniques are applied:
(1)
yt = ayt + (1 a)yt1
(2)
4/65
Introduction
Descriptive Analysis
Preliminary goal of this analysis: examine the main features of the graph and check
whether there is:
a) a trend component (linear, quadratic, . . .);
b) a seasonal component;
c) a cyclical component;
d) any apparent sharp changes in behavior;
e) any outlying observations.
5/65
Introduction
Probabilistic Approach
The observed time series {yt }tZ is a realization or sample of an underlying unknown
stochastic process {Yt }tZ .
Final goal of the analysis:
explore the main characteristics of the underlying stochastic process, given the
information included in the observed sample.
note that almost all modern economic time-series are not stationary and when
transforming the data some important information on the original stochastic
process can be lost.
6/65
Introduction
Probabilistic Approach
Possible solution:
if this linear combination returns a series that is stationary, then the two series
have a common stochastic trend or permanent component
7/65
upward trend and seasonal pattern with peaks in July and troughs in January.
8/65
strong seasonal pattern, with maximum for each year occurring in July and
minimum in February
9/65
upward trend is evident, can fit a quadratic or exponential trend to the data.
10/65
11/65
12/65
13/65
14/65
the final goal of time series analysis is to introduce some techniques for
drawing inferences from time series yt , t = 1, . . . , T of realizations.
Then: fit the model to the data, estimate the parameters, check of goodness
of fit to the data, use the fitted model to enhance understanding of the
stochastic mechanism generating the series, use the model for prediction and
other applications of interest.
For the interpretation of the results (from both a statistical and an economic
point-of-view), it is important to recognize and eliminate the presence of
disturbing quantities like seasonal and/or other noisy components.
15/65
Basic Concepts
Some Definitions
Definitions
a time series model for the observed data {xt } is a specification of the joint
distributions of the time series {Xt : t Z} for which {xt } is postulated to be
a realization.
Remark
The definition above naturally extends to a multivariate vector of random variables.
16/65
Basic Concepts
Some Definitions
the laws of such a stochastic process are completely determined by the joint
distributions of every set of variables (Xt1 , Xt2 , . . . , Xtk ), k = 1, 2, . . .:
P [Xt1 xt1 , Xt2 xt2 , . . . , Xtk xtk ]
(3)
(4)
In this case, the laws are (at least partially) characterized only by the first two
moments (what are moment?)
17/65
Basic Concepts
Examples of Time Series
1
.
2
18/65
Basic Concepts
Examples of Time Series
population in the US
19/65
Basic Concepts
Examples of Time Series
(5)
20/65
Basic Concepts
Examples of Time Series
k
X
aj cos(j t) + bj sin(j t) ,
j=1
21/65
Basic Concepts
Examples of Time Series
The parameters 1 , . . . , k are fixed frequencies, each being some integer multiple of
2/d.
(6)
We should thus choose k = 2 which will have periods twelve and six months.
Australian red wine sales:
From the earlier graph: both a trend and a seasonal pattern are visible.
build up a model with both trend and periodic components, of the form
Xt = mt + st + Yt ,
(7)
22/65
Basic Concepts
General Approach to Time Series Modeling
23/65
Basic Concepts
Introduction to Stationary Models
24/65
Basic Concepts
Autocovariance and Autocorrelation functions
(8)
Note that in this case X (0) = Var(Xt ) independent of t and the process
{Xt , t Z} is homoskedastic.
Let us define now the autocovariance and autocorrelation functions. Note that
X (h) = X (h) (symmetry).
Definition: Let {Xt , t Z} be a stationary time series. The autocovariance
function (ACVF) of {Xt } at lag h is
X (h) = Cov(Xt+h , Xt ).
(9)
(10)
25/65
Basic Concepts
Examples
Examples
iid noise.
If {Xt } is iid noise and E[Xt2 ] = 2 < , then
2
,
X (t + h, t) =
0,
if h = 0,
if h =
6 0
(11)
26/65
Basic Concepts
Examples
(12)
E[Xt ] = independent of t;
E[Xt2 ] = 2 + 2 (1 + 2 ) < ;
27/65
Basic Concepts
Examples
and
2
(1 + 2 ) ,
2 ,
X (t + h, t) =
0,
if h = 0,
if h {1; +1},
if | h |> 1
(13)
(14)
28/65
Basic Concepts
Examples
E[Xt ] =
E[Xt2 ] = 2 +
X (h) =
= constant;
X (h)
X (0)
2
12
< ;
2
;
12
= |h| , h Z.
29/65
Basic Concepts
Sample Autocovariance and Autocorrelation functions
We can compute sample autocorrelation function (sample ACF), to assess the degree
of dependence in the data and then to select a model for the data that reflect this.
Definitions: Let {xi }n
i=1 be observations of a time series. The sample mean of
x1 , . . . , xn is computed as
n
1X
xt .
(15)
x=
n t=1
The sample autocovariance function at lag h is
(h) =
n|h|
1 X
(xt+|h| x)(xt x), n < h < n.
n t=1
(16)
(h)
, n < h < n.
(0)
(17)
30/65
Basic Concepts
Sample Autocovariance and Autocorrelation functions Examples: iid Noise
Since (h) = 0 for h > 0 in the model, sample autocorrelations should be near 0.
Asymptotic theory: (h), h > 0 approximately IID N (0, 1/n) for n hlarge.
i
+1.96
31/65
Basic Concepts
Sample Autocovariance and Autocorrelation functions Examples: a nonstationary example
32/65
Basic Concepts
Sample Autocovariance and Autocorrelation functions Examples: test of model residuals
Figure 10: ACF of Population in the US and ACF of residuals form a quadratic time trend
regression
We have seen that we can fit a model with a quadratic trend to this series.
33/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
34/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
In the classical decomposition, the realization of the process are modelled as:
Xt = mt + st + Yt ,
where mt is a slowly changing function, st is a function with known period d and Yt
is a cyclical component that is stationary, with E(Yt ) = 0.
Nonseasonal Model with Trend
Xt = mt + Yt , t = 1, . . . , n, where E[Yt ] = 0.
Method 1: Trend estimation
Final goal: find an estimate m
t for the trend component function mt .
35/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
j=
36/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
Then for q + 1 t n q,
Wt
q
X
1
Xtj
2q + 1 j=q
(18)
q
q
X
X
1
1
mtj +
Ytj
2q + 1 j=q
2q + 1 j=q
(19)
mt
(20)
and
m
t =
q
X
j=q
1
Xtj ,
2q + 1
37/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
b) Exponential smoothing:
Compute the one-sided moving averages {m
t } as
m
t = Xt + (1 )m
t1 , t = 2, . . . , n, fixed [0, 1].
Take as initial value m
1 = X1 .
This model is often referred to as exponential smoothing, since for t 2
m
t =
t2
X
(1 )j Xtj + (1 )t1 X1 .
(21)
j=0
38/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
39/65
Basic Concepts
Example. Strikes in the US
Number of strikes per year in the US. Time period: from 1951 to 1980.
40/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
(22)
41/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
42/65
Basic Concepts
Example: Population in the US.
For population in the US already introduced above we find that differencing twice is
sufficient to produce a series with no apparent trend, ie.
{xt } {2 xt } = {xt 2xt1 + xt2 }.
43/65
Basic Concepts
Example: S&P500 Stock price index.
For daily US S&P500 Index values the trend evident in the data can be easily
eliminated by differencing once, that is:
{xt } {xt } = {xt xt1 }.
44/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
Xt = mt + st + Yt , t = 1, . . . , n,
Pd
= st and
j=1 sj = 0.
(23)
45/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
3) Let
dt = xt st , t = 1, . . . , n,
(24)
46/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
(25)
Remark: Note that the re-estimation of the trend in step 3. above is done in order to
have a parametric form for the trend that can be used for simulation and prediction.
Method 2: Elimination of trend and seasonal components by differencing
Define the lag-d differencing operator d by
d Xt = Xt Xtd = (1 Ld )Xt .
(26)
47/65
Basic Concepts
Estimation and Elimination of Both Trend and Seasonality
(27)
48/65
Basic Concepts
Example: Accidental deaths in the US.
49/65
Basic Concepts
Testing the Estimated Residual Sequence
To determine this: use simple tests for checking the hypothesis that the residuals are
observed values of iid random variables.
50/65
Basic Concepts
Testing the Estimated Residual Sequence
h
X
(28)
j=1
QLB = n(n + 2)
h
X
2 (j)
(Ljung-Box test)
nj
j=1
(29)
51/65
Basic Concepts
Testing the Estimated Residual Sequence
QML = n(n + 2)
h
X
2W W (j)
(McLeod-Li test)
nj
j=1
(30)
52/65
Basic Concepts
Testing the Estimated Residual Sequence
53/65
Basic Concepts
Testing the Estimated Residual Sequence
2
In fact: for an iid sequence with large n: NT P N (NT P , N
).
TP
(31)
54/65
Basic Concepts
Testing the Estimated Residual Sequence
(32)
55/65
Basic Concepts
Testing the Estimated Residual Sequence
1
n(n
2
(33)
(34)
56/65
Basic Concepts
Testing the Estimated Residual Sequence
2
N
= V (NP )
P
(35)
57/65
Basic Concepts
Example: Accidental deaths in the US.cont.
58/65
Basic Concepts
Example: Accidental deaths in the US. cont.
59/65
Basic Concepts
Lag (or Backshift) Operator
(36)
Xt = Xt1 + Yt (1 L)Xt = Yt
(37)
Lc = c, where c is a constant.
(38)
60/65
Basic Concepts
Lag (or Backshift) Operator
61/65
Basic Concepts
Lag (or Backshift) Operator
evaluation in L = 1:
a(1) = a0 + a1 + . . . + an =
n
X
ai
(39)
i=0
first derivative:
d
a(L) = a0 (L) = a1 + 2a2 L + 3a3 L2 + . . . + nan Ln1 .
dL
Then
a0 (1) = a1 + 2a2 + . . . + nan =
n
X
iai .
(40)
(41)
i=1
(42)
62/65
Exercises
1) Let {Zt } be a sequence of independent normal random variables, each with mean 0 and variance
2 , and let a, b and c be constants. Which, if any, of the following processes are stationary? For
each stationary process specify the mean and autocovariance function.
a) Xt = a + bZt + cZt2 ;
b) Xt = Zt cos(ct) + Zt1 sin(ct);
c) Xt = a + bZ0 ;
d) Xt = Zt Zt1 .
2) Let {Xt } be a moving average process of order 2 given by
Xt = Zt + Zt2 , where Zt WN(0, 1).
(43)
a) Find the autocovariance and autocorrelation functions for this process when = 0.8.
P
b) Compute the variance of the sample mean X 4 = 14 4j=1 Xj .
c) Repeat b) when = 0.8 and compare your answer with the result obtained in b)
63/65
Exercises
(44)
a) If mt = c0 + c1 t, show that
Pq
j=q
, q j q.
(45)
aj mtj = mt .
2
.
2q+1
64/65
Exercises
5) Let {Yt } be a stationary process with mean zero and let a and b be constants. If
Xt = a + bt + st + Yt ,
(46)
12
)Xt
(47)
(49)
g2 = a2 + g1
etc.
Compute g(1).
65/65