Download Univariate Time Series Analysis

Document related concepts
no text concepts found
Transcript
Univariate Time Series Analysis
Univariate Time Series Analysis
Klaus Wohlrabe1 and Stefan Mittnik
1
Ifo Institute for Economic Research, [email protected]
SS 2016
1 / 442
Univariate Time Series Analysis
1
Organizational Details and Outline
2
An (unconventional) introduction
Time series Characteristics
Necessity of (economic) forecasts
Components of time series data
Some simple filters
Trend extraction
Cyclical Component
Seasonal Component
Irregular Component
Simple Linear Models
3
A more formal introduction
4
(Univariate) Linear Models
Notation and Terminology
Stationarity of ARMA Processes
Identification Tools
2 / 442
Univariate Time Series Analysis
5
Modeling ARIMA Processes: The Box-Jenkins Approach
Estimation of Identification Functions
Identification
Estimation
Yule-Walker Estimation
Least Squares Estimators
Maximum Likelihood Estimator (MLE)
Model specification
Diagnostic Checking
6
Prediction
Some Theory
Examples
Forecasting in Practice
A second Case Study
Forecasting with many predictors
7
Trends and Unit Roots
3 / 442
Univariate Time Series Analysis
Stationarity vs. Nonstationarity
Testing for Unit Roots: Dickey-Fuller-Test
Testing for Unit Roots: KPSS
8
Models for financial time series
ARCH
GARCH
GARCH: Extensions
4 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content I
1
Organizational Details and Outline
2
An (unconventional) introduction
Time series Characteristics
Necessity of (economic) forecasts
Components of time series data
Some simple filters
Trend extraction
Cyclical Component
Seasonal Component
Irregular Component
Simple Linear Models
3
A more formal introduction
4
(Univariate) Linear Models
Notation and Terminology
5 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content II
Stationarity of ARMA Processes
Identification Tools
5
Modeling ARIMA Processes: The Box-Jenkins Approach
Estimation of Identification Functions
Identification
Estimation
Yule-Walker Estimation
Least Squares Estimators
Maximum Likelihood Estimator (MLE)
Model specification
Diagnostic Checking
6
Prediction
Some Theory
Examples
Forecasting in Practice
6 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content III
A second Case Study
Forecasting with many predictors
7
Trends and Unit Roots
Stationarity vs. Nonstationarity
Testing for Unit Roots: Dickey-Fuller-Test
Testing for Unit Roots: KPSS
8
Models for financial time series
ARCH
GARCH
GARCH: Extensions
7 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Introduction
Time series analysis:
Focus: Univariate Time Series and Multivariate Time
Series Analysis.
A lot of theory and many empirical applications with real
data
Organization:
12.04. - 24.05.: Univariate Time Series Analysis, six
lectures (Klaus Wohlrabe)
31.05. - End of Semester: Multivariate Time Series
Analysis (Stefan Mittnik)
15.04. - 27.05. mondays and fridays: Tutorials (Univariate):
Malte Kurz, Elisabeth Heller
⇒ Lectures and Tutorials are complementary!
8 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Introduction
Time series analysis:
Focus: Univariate Time Series and Multivariate Time
Series Analysis.
A lot of theory and many empirical applications with real
data
Organization:
12.04. - 24.05.: Univariate Time Series Analysis, six
lectures (Klaus Wohlrabe)
31.05. - End of Semester: Multivariate Time Series
Analysis (Stefan Mittnik)
15.04. - 27.05. mondays and fridays: Tutorials (Univariate):
Malte Kurz, Elisabeth Heller
⇒ Lectures and Tutorials are complementary!
8 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Introduction
Time series analysis:
Focus: Univariate Time Series and Multivariate Time
Series Analysis.
A lot of theory and many empirical applications with real
data
Organization:
12.04. - 24.05.: Univariate Time Series Analysis, six
lectures (Klaus Wohlrabe)
31.05. - End of Semester: Multivariate Time Series
Analysis (Stefan Mittnik)
15.04. - 27.05. mondays and fridays: Tutorials (Univariate):
Malte Kurz, Elisabeth Heller
⇒ Lectures and Tutorials are complementary!
8 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Introduction
Time series analysis:
Focus: Univariate Time Series and Multivariate Time
Series Analysis.
A lot of theory and many empirical applications with real
data
Organization:
12.04. - 24.05.: Univariate Time Series Analysis, six
lectures (Klaus Wohlrabe)
31.05. - End of Semester: Multivariate Time Series
Analysis (Stefan Mittnik)
15.04. - 27.05. mondays and fridays: Tutorials (Univariate):
Malte Kurz, Elisabeth Heller
⇒ Lectures and Tutorials are complementary!
8 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Tutorials and Script
Script is available at: moodle website (see course website)
Password: armaxgarchx
Script is available at the day before the lecture (noon)
All datasets and programme codes
Tutorial: Mixture between theory and R - Examples
9 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Literature
Shumway and Stoffer (2010): Time Series Analysis and
Its Applications: With R Examples
Box, Jenkins, Reinsel (2008): Time Series Analysis:
Forecasting and Control
Lütkepohl (2005): Applied Time Series Econometrics.
Hamilton (1994): Time Series Analysis.
Lütkepohl (2006): New Introduction to Multiple Time Series
Analysis
Chatham (2003): The Analysis of Time Series: An
Introduction
Neusser (2010): Zeitreihenanalyse in den
Wirtschaftswissenschaften
10 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Examination
Evidence of academic achievements: Two hour written
exam both for the univariate and multivariate part
Schedule for the Univariate Exam: 30/05 (to be
confirmed!!!)
11 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Prerequisites
Basic Knowledge (ideas) of OLS, maximum likelihood
estimation, heteroscedasticity, autocorrelation.
Some algebra
12 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Software
Where you have to pay:
STATA
Eviews
Matlab (Student version available, about 80 Euro)
Free software:
R (www.r-project.org)
Jmulti (www.jmulti) (Based on the book by Lütkepohl
(2005))
13 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Tools used in this lecture
usual standard lecture (as you might expected)
derivations using the whiteboard (not available in the
script!)
live demonstrations (examples) using Excel, Matlab,
Eviews, Stata and JMulti
live programming using Matlab
14 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Outline
Introduction
Linear Models
Modeling ARIMA Processes: The Box-Jenkins Approach
Prediction (Forecasting)
Nonstationarity (Unit Roots)
Financial Time Series
15 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Goals
After the lecture you should be able to ...
... identify time series characteristics and dynamics
... build a time series model
... estimate a model
... check a model
... do forecasts
... understand financial time series
16 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Questions to keep in mind
General Question
How are the variables defined?
What is the relationship between the data and the phenomenon of interest?
Who compiled the data?
What processes generated
the data?
What is the frequency of
measurement
What is the type of measurement?
Are the data seasonally adjusted?
Follow-up Questions
All types of data
What are the units of measurement? Do the data comprise a sample? Ifo so, how was the sample drawn?
Are the variables direct measurements of the phenomenon of interest, proxies, correlates, etc.?
Is the data provider unbiased? Does the provider possess the skills and resources to enure data quality and
integrity?
What theory or theories can account for the relationships
between the variables in the data?
Time Series data
Are the variables measured hourly, daily monthly, etc.?
How are gaps in the data (for example, weekends and
holidays) handled?
Are the data a snapshot at a point in time, an average
over time, a cumulative value over time, etc.?
If so, what is the adjustment method? Does this method
introduce artifacts in the reported series?
17 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content I
1
Organizational Details and Outline
2
An (unconventional) introduction
Time series Characteristics
Necessity of (economic) forecasts
Components of time series data
Some simple filters
Trend extraction
Cyclical Component
Seasonal Component
Irregular Component
Simple Linear Models
3
A more formal introduction
4
(Univariate) Linear Models
Notation and Terminology
18 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content II
Stationarity of ARMA Processes
Identification Tools
5
Modeling ARIMA Processes: The Box-Jenkins Approach
Estimation of Identification Functions
Identification
Estimation
Yule-Walker Estimation
Least Squares Estimators
Maximum Likelihood Estimator (MLE)
Model specification
Diagnostic Checking
6
Prediction
Some Theory
Examples
Forecasting in Practice
19 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content III
A second Case Study
Forecasting with many predictors
7
Trends and Unit Roots
Stationarity vs. Nonstationarity
Testing for Unit Roots: Dickey-Fuller-Test
Testing for Unit Roots: KPSS
8
Models for financial time series
ARCH
GARCH
GARCH: Extensions
20 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Goals and methods of time series analysis
The following section partly draws upon Levine, Stephan,
Krehbiel, and Berenson (2002), Statistics for Managers.
21 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Goals and methods of time series analysis
understanding time series characteristics and dynamics
necessity of (economic) forecasts (for policy)
time series decomposition (trends vs. cycle)
smoothing of time series (filtering out noise)
moving averages
exponential smoothing
22 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Time Series
A time series is timely ordered sequence of observations.
We denote yt as an observation of a specific variable at
date t.
A time series is list of observations denoted as
{y1 , y2 , . . . , yT } or in short {yt }Tt=1 .
What are typical characteristics of times series?
23 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: GDP I
80
85
90
GDP
95
100
105
Germany: GDP (seasonal and workday-adjusted, Chain index)
1990q1
1995q1
2000q1
2005q1
time
2010q1
2015q1
24 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: GDP II
Germany: Yearly GDP growth
-10
-4
-5
Yearly GDP growth
0
Quarterly GDP growth
0
-2
5
2
Germany: Quarterly GDP growth
1990q1
1995q1
2000q1
2005q1
time
2010q1
2015q1
1990q1
1995q1
2000q1
2005q1
time
2010q1
2015q1
25 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Retail Sales
0
Retail Sales - Chain Index
100
50
150
Germany: Retail Sales - non-seasonal adjusted
1950m1
1960m1
1970m1
1980m1
time
1990m1
2000m1
2010m1
26 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Industrial Production
20
40
60
IP
80
100
120
Germany: Industrial Production (non-seasonal adjusted, Chain index)
1950m1
1960m1
1970m1
1980m1
time
1990m1
2000m1
2010m1
27 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Industrial Production
Germany: Yearly GIP growth
-40
-20
-10
-20
Yearly IP growth
0
Monthly IP growth
0
10
20
20
30
40
Germany: Monthly IP growth
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1
time
time
28 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: The German DAX
Return
0
-.06
-.04
5000
-.02
DAX
Return
0
10000
.02
.04
15000
Level
0
2000
4000
6000
8000
0
2000
4000
6000
29 / 442
8000
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Gold Price
Return
0
-.1
500
-.05
Gold
1000
Return
0
1500
.05
2000
Level
0
2000
4000
6000
8000
10000
0
2000
4000
6000
8000
30 / 442
10000
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
0
50
Sunspots
100
150
200
Further Time Series: Sunspots
1700
1800
1900
2000
time
31 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
4
4.5
ECG
5
5.5
6
Further Time Series: ECG
0
2000
4000
6000
8000
10000
Time
32 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
-2
-1
0
AR
1
2
3
Further Time Series: Simulated Series: AR(1)
0
20
40
60
Time
80
100
33 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
-10
-5
0
5
Further Time Series: Chaos or a real time series?
1990m1
1995m1
2000m1
2005m1
time
2010m1
2015m1
34 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
-4
-2
0
2
4
Further Time Series: Chaos?
0
20
40
60
Time
80
100
35 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Characteristics of Time series
Trends
Periodicity (cyclicality)
Seasonality
Volatility Clustering
Nonlinearities
Chaos
36 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Necessity of (economic) forecasts
Necessity of (economic) Forecasts
For political actions and budget control governments need
forecasts for macroeconomic variables
GDP, interest rates, unemployment rate, tax revenues etc.
marketing need forecasts for sales related variables
future sales
product demand (price dependent)
changes in preferences of consumers
37 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Necessity of (economic) forecasts
Necessity of (economic) Forecasts
retail sales company need forecasts to optimize
warehousing and employment of staff
firms need to forecasts cash-flows in order to account of
illiquidity phases or insolvency
university administrations needs forecasts of the number of
students for calculation of student fees, staff planning,
space organization
migration flows
house prices
38 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Components of time series data
Time series decomposition
Trend
Cyclical
Time Series
Seasonal
Irregular
39 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Components of time series data
Time series decomposition
Classical additive decomposition:
yt = dt + ct + st + t
(1)
dt trend component (deterministic, almost constant over
time)
ct cyclical component (deterministic, periodic, medium
term horizons)
st seasonal component (deterministic, periodic; more than
one possible)
t irregular component (stochastic, stationary)
40 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Components of time series data
Time series decomposition
Goal:
Extraction of components dt , ct and st
The irregular component
t = yt − dt − ct − st
should be stationary and ideally white noise.
Main task is then to model the components appropriately.
Data transformation maybe necessary to account for
heteroscedasticity (e.g. log-transformation to stabilize
seasonal fluctuations)
41 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Components of time series data
Time series decomposition
The multiplicative model:
yt = dt · ct · st · t
(2)
will be treated in the tutorial.
42 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Simple Filters
series = signal + noise
(3)
The statistician would says
series = fit + residual
(4)
series = model + errors
(5)
At a later stage:
⇒ mathematical function plus a probability distribution of
the error term
43 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Linear Filters
A linear filter converts one times series (xT ) into another (yt ) by
the linear operation
+s
X
yt =
ar xt+r
r =−q
where ar is a set of weights. In order to smooth local fluctuation
one should chose the weight such that
X
ar = 1
44 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
The idea
yt = f (t) + t
(6)
We assume that f (t) and t are well-behaved.
Consider N observations at time tj which are reasonably close
in time to ti . One possible smoother ist
X
X
X
X
yt∗i = 1/N
ytj = 1/N
f (tj ) + 1/N
tj ≈ f (ti ) + 1/N
tj
(7)
if t ∼ N(0, σ 2 ), the variance of the sum of the residuals is
σ 2 /N 2 .
The smoother is characterized by
span, the number of adjacent points included in the
calculation
type of estimator (median, mean, weighted mean etc.)
45 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
Used for time series smoothing.
Consists of a series of arithmetic means.
Result depends on the window size L (number of included
periods to calculate the mean).
In order to smooth the cyclical component, L should
exceed the cycle length
L should be uneven (avoids another cyclical component)
46 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
MA(yt ) =
+q
X
1
yt+r
2q + 1 r =−q
L = 2q + 1
where the weights are given by
ar =
1
2q + 1
47 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
Example: Moving Average (MA) over 3 Periods
y1 +y2 +y3
3
MA3 (3) = y2 +y33 +y4
First MA term: MA2 (3) =
Second MA term:
48 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
49 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
IP
M A(3)
M A(5)
140
140
120
120
120
100
100
100
80
80
60
60
40
40
20
20
0
0
80
60
50
55
60
65
70
75
80
85
90
95
00
05
10
40
20
0
50
55
60
65
70
M A(7)
75
80
85
90
95
00
05
10
50
120
120
100
100
100
80
80
80
60
60
60
40
40
40
20
20
0
0
55
60
65
70
75
80
85
90
95
00
05
10
120
100
100
80
80
60
60
40
40
20
20
0
65
70
75
80
85
90
95
00
05
10
75
80
85
90
95
00
05
10
90
95
00
05
10
90
95
00
05
10
0
55
60
65
70
75
80
85
90
95
00
05
10
50
55
60
65
70
75
80
85
M A(101)
110
100
90
80
70
60
50
40
30
0
60
70
M A(51)
120
55
65
20
50
M A(25)
50
60
M A(11)
120
50
55
M A(9)
20
50
55
60
65
70
75
80
85
90
95
00
05
10
50
55
60
65
70
75
80
85
⇒ the larger L the smoother and shorter the filtered series
50 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
EXAMPLE
Generate a random time series (normally distributed) with
T = 20
Quick and dirty: Moving Average with Excel
Nice and Slow: Write a simple Matlab program for
calculating a moving average of order L
Additional Task: Increase the number of observations to
T = 100, include a linear time trend and calculate different
MAs
Variation: Include some outliers and see how the
calculations change.
51 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
weighted moving averages
latest observation has the highest weight compared to the
previous periods
ŷt = wyt + (1 − w)ŷt−1
Repeated substitution gives:
ŷt = w
t−1
X
(1 − w)s yt−s
s=0
⇒ that’s why it is called exponential smoothing, forecasts are
the weighted average of past observations where the weights
decline exponentially with time.
52 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
Is used for smoothing and short–term forecasting
Choice of w:
subjective or through calibration
numbers between 0 and 1
Close to 0 for smoothing out unpleasant cyclical or irregular
components
Close to 1 for forecasting
53 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
ŷt = wyt + (1 − w)ŷt−1
w = 0.2
54 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
IP
w=0.05
140
120
120
100
100
80
80
60
60
40
40
20
0
50
55
60
65
70
75
80
85
90
95
00
05
10
20
50
55
60
65
70
75
w=0.2
85
90
95
00
05
10
90
95
00
05
10
w=0.95
120
140
100
120
100
80
80
60
60
40
40
20
0
80
20
50
55
60
65
70
75
80
85
90
95
00
05
10
0
50
55
60
65
70
75
80
85
55 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Trend Component
positive or negative trend
observed over a longer time horizon
linear vs. non–linear trend
smooth vs. non–smooth trends
⇒ trend is ’unobserved’ in reality
56 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Trend Component: Example
Linear trend with a cyclical component
Nonlinear trend with cyclical component
24
3.0
20
2.5
16
2.0
12
1.5
8
1.0
4
0.5
0
25
50
75
100
125
150
175
200
0.0
25
50
75
100
125
150
175
200
57 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Why is trend extraction so important?
The case of detrending GDP
trend GDP is denoted as potential output
The difference between trend and actual GDP is called the
output gap
Is an economy below or above the current trend? (Or is the
output gap positive or negative?)
⇒ consequences for economic policy (wages, prices etc.)
Trend extraction can be highly controversial!
58 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Linear Trend Model
Year
05
06
07
08
09
10
Time (xt )
1
2
3
4
5
6
Turnover (yt )
2
5
2
2
7
6
yt = α + βxt
59 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Linear Trend Model
Estimation with OLS
ŷt = α̂ + β̂xt = 1.4 + 0.743xt
Forecast for 2011:
ŷ2011 = 1.4 + 0.743 · 7 = 6.6
60 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Quadratic Trend Model
Year
05
06
07
08
09
10
Time (xt )
1
2
3
4
5
6
Time2 (xt2 )
1
4
9
16
25
36
Turnover (yt )
2
5
2
2
7
6
yt = α + β1 xt + β2 xt2
61 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Quadratic Trend Model
ŷt = α̂ + β̂xt + βˆ2 xt2 = 3.4 − 0.757143xt + 0.214286xt2
Forecast for 2011:
ŷ2011 = 3.4 − 0.757143 · 7 + 0.214286 · 72 = 8.6
62 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Exponential Trend Model
Year
05
06
07
08
09
10
Time (xt )
1
2
3
4
5
6
Turnover (yt )
2
5
2
2
7
6
yt = αβ1xt
⇒ Non-linear Least Squares (NLS) or
Linearize the model and use OLS:
log yt = log α + log(β1 )xt
⇒ ’relog’ the model
63 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Exponential Trend Model
Estimation via NLS:
xt
ŷt = α̂ + βˆ1 = 0.08 · 1.93xt
Forecast for 2011:
ŷ2011 = 0.08 · 1.937 = 15.4
64 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Logarithmic Trend Model
Year
05
06
07
08
09
10
Time (xt )
1
2
3
4
5
6
log(Time)
log(1)
log(2)
log(3)
log(4)
log(5)
log(6)
Turnover (yt )
2
5
2
2
7
6
Logarithmic Trend:
yt = α + β1 log xt
65 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Logarithmic Trend Model
Estimation via OLS:
ŷt = α̂ + βˆ1 log xt = 1.934675 + 1.883489 · log yt
Forecast for 2011:
Ŷ2011 = 1.934675 + 1.883489 · log(7) = 5.6
66 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Comparison of different trend models
8
7
6
5
4
3
2
1
2005
2006
2007
TURNOVER
Logarithmic Trend
Exponential Trend
2008
2009
2010
Linear Trend
Quadratic Trend
67 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Detrending GDP
120
110
100
90
80
70
60
92
94
96
98
00
GDP
Logarithmic Trend
02
04
06
08
10
12
Linear Trend
Quadratic Trend
68 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Which trend model to choose?
Linear Trend model, if the first differences
yt − yt−1
are stationary
Quadratic trend model, if the second differences
(yt − yt−1 ) − (yt−1 − yt−2 )
are stationary
Logarithmic trend model, if the relative differences
yt − yt−1
yt
are stationary
69 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
The Hodrick-Prescott-Filter (HP)
The HP extracts a flexible trend. The filter is given by
T
T
−1
X
X
2
min
[(yt − µt ) + λ
{(µt+1 − µt ) − (µt − µt−1 )}2 ]
µt
t=1
(8)
t=2
where µt is the flexible trend and λ a smoothness parameter
chosen by the researcher.
As λ approaches infinity we obtain a linear trend.
Currently the most popular filter in economics.
70 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
The Hodrick-Prescott-Filter (HP)
How to choose λ?
Hodrick-Prescot (1997) recommend:


100 for annual data
λ = 1600 for quarterly data


14400 for monthly data
(9)
Alternative: Ravn and Uhlig (2002)
71 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
The Hodrick-Prescott-Filter (HP)
112
108
104
100
96
92
88
84
80
76
92
94
96
98
00
02
04
IP
Lambda a.t. Ravn and Uhlig (2002)
Lambda = 10,000,000
06
08
10
12
Lambda = 14,400
Lambda = 50,000
72 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
The Hodrick-Prescott-Filter (HP)
12
8
4
0
-4
-8
-12
-16
92
94
96
98
Lambda = 14,400
Lambda = 50,000
00
02
04
06
08
10
12
Lambda a.t. Ravn and Uhlig (2002)
Lambda = 10,000,000
73 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Problems with the HP-Filter
λ is a ’tuning’ parameter
end of sample instability
⇒ AR-forecasts
74 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Case study for German GDP: Where are we now?
80
85
90
GDP
95
100
105
Germany: GDP (seasonal and workday-adjusted, Chain index)
1990q1
1995q1
2000q1
2005q1
2010q1
2015q1
time
75 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
HP-Filter
Hodrick-Prescott Filter (lambda=1600)
110
105
100
95
90
4
85
2
80
75
0
-2
-4
-6
92
94
96
98
00
GDP
02
04
Trend
06
08
10
12
14
Cycle
76 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Can we test for a trend?
Yes and no
If the trend component significant?
several trends can be significant
Trend might be spurious
Is it plausible that there is a trend?
A priori information by the researcher
unit roots
77 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
EXAMPLE
Time series: Industrial Production in Germany
(1991:01-2014:02)
Plot the time series and state which trend adjustment
might be appropriate
Prepare your data set in Excel and estimate various trends
in Eviews
Which trend would you choose?
78 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component
is not always present in time series
Is the difference between the observed time series and the
estimated trend
In economics
characterizes the Business cycle
different length of cycles (3-5 or 10-15 years)
79 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component: Example
Hodrick-Prescott Filter (lambda=14400)
120
110
100
90
10
80
5
70
0
-5
-10
-15
92
94
96
98
00
IP
02
04
Trend
06
08
10
12
14
Cycle
80 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
0
50
Sunspots
100
150
200
Cyclical Component: Example II
1700
1800
1900
2000
time
81 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
4
4.5
ECG
5
5.5
6
Cyclical Component: Example III
0
2000
4000
6000
8000
10000
Time
82 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Can we test for a cyclical component?
Yes and no
see the trend section
Does a cycle make sense?
83 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Component
similar upswings and downswings in a fixed time interval
regular pattern, i.e. over a year
0
Retail Sales - Chain Index
50
100
150
Germany: Retail Sales - non-seasonal adjusted
1950m1
1960m1
1970m1
1980m1
time
1990m1
2000m1
2010m1
84 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Types of Seasonality
A: yt = mt + St + t
B: yt = mt St + t
C: yt = mt St t
Model A is additive seasonal, Models B and C contains
multiplicative seasonal variation
85 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Types of Seasonality
if the seasonal effect is constant over the seasonal periods
⇒ additive seasonality (Model A)
if the seasonal effect is proportional to the mean
⇒ multiplicative seasonality (Model A and B)
in case of multiplicative seasonal models use the
logarithmic transformation to make the effect additive
86 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Adjustment
Simplest Approach to seasonal adjustment:
Run the time series on a set of dummies without a constant
(Assumes that the seasonal pattern is constant over time)
the residuals of this regression are seasonal adjusted
Example: Monthly data
yt
=
12
X
βi Di + t
i=1
t
= yt −
12
X
β̂Di
i=1
yt,sa = t + mean(yt )
The most well known seasonal adjustment procedure:
CENSUS X12 ARIMA
87 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Adjustment: Dummy Regression Example
140
130
120
110
100
90
15
80
10
5
0
-5
-10
1992
1994
1996
1998
Residual
2000
2002
Actual
2004
2006
2008
Fitted
88 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Adjustment: Example
Seasonal Adjustement Retail Sales
Original Series
140
130
120
110
100
90
80
Dummy Approach
92
94
96
98
00
02
112
110
108
105
104
100
100
95
96
90
92
94
96
98
00
02
04
04
06
08
10
Arima X12
115
06
08
10
92
92
94
96
98
00
02
04
06
08
10
89 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Moving Averages
For monthly data one can employ the filter
SMA(yt ) =
1
2 yt−6
+ yt−5 + yt−4 + . . . + yt+6 + 12 yt+6
12
or for quarterly data
SMA(yt ) =
1
2 yt−2
+ yt−1 + yt + yt+1 + 12 yt+2
4
Note: The weights add up to one!
Standard moving average not applicable
90 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Moving Averages: Retail Sales Example
120
100
80
60
40
20
0
50
55
60
65
70
75
80
Moving Seasonal Average
85
90
95
00
05
10
Dummy Approach
91 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Differencing
seasonal effect can be eliminated using the a simple linear
filter
in case of a monthly time series: ∆12 yt = yt − yt−12
in case of a quarterly time series: ∆4 yt = yt − yt−4
92 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Differencing: Retail Sales Example
Differenced Month
Year Differenced
16
30
12
20
10
8
0
4
-10
0
-20
-4
-30
-8
-12
-40
50 55 60 65 70 75 80 85 90 95 00 05 10
-50
50 55 60 65 70 75 80 85 90 95 00 05 10
93 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Can we test for seasonality?
Yes and no
Does seasonality makes sense?
Compare the seasonal adjusted and unadjusted series
look into the ARIMA X12 output
Be aware of changing seasonal patterns
94 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
EXAMPLE
Time series: seasonally unadjusted Industrial Production in
Germany (1950:01-2011:02)
Remove the seasonality by a moving seasonal filter
Try the dummy approach
Finally, use the ARIMAX12-Approach
Start the sample in 1991:01 and compare all filters with the
full sample
95 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Irregular Component
Irregular Component
erratic, non-systematic, random "residual" fluctuations due
to random shocks
in nature
due to human behavior
no observable iterations
96 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Irregular Component
Can we test for an irregular component?
YES
several tests available whether the irregular component is
a white noise or not
97 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
White Noise
A process {yt } is called white noise if
E(yt ) = 0
γ(0) = σ 2
γ(h) = 0 for |h| > 0
⇒ all yt ’s are uncorrelated. We write: {yt } ∼ WN(0, σ 2 )
98 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
White Noise
White Noise with Variance = 1
4
4
2
2
0
0
-2
-2
3
2
1
0
-1
-2
-4
-4
10
20
30
40
50
60
70
80
90
-3
10
100
20
30
40
50
60
70
80
90
100
3
3
3
2
2
2
1
1
1
0
0
0
-1
-1
-1
-2
-2
-3
20
30
40
50
60
70
80
90
3
30
40
50
60
70
80
90
100
10
20
30
40
50
60
70
80
90
100
10
20
30
40
50
60
70
80
90
100
-3
10
100
20
-2
-3
10
10
20
30
40
50
60
70
80
90
100
4
3
2
2
2
1
1
0
0
0
-1
-1
-2
-2
-2
-3
-4
10
20
30
40
50
60
70
80
90
100
-3
10
20
30
40
50
60
70
80
90
100
99 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
White Noise
WN with Variance = 1
White Noise with Variance = 2
2
6
4
1
2
0
0
-1
-2
-2
-3
-4
10
20
30
40
50
60
70
80
90
100
-6
10
White Noise with Variance = 10
30
40
50
60
70
80
90
100
90
100
White Noise with Variance = 100
30
300
20
200
100
10
0
0
-100
-10
-200
-20
-30
20
-300
10
20
30
40
50
60
70
80
90
100
-400
10
20
30
40
50
60
70
80
100 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Random Walk (with drift)
A simple random walk is given by
yt = yt−1 + t
By adding a constant term
yt = c + yt−1 + t
we get a random walk with drift. It follows that
yt = ct +
t
X
j
j=1
101 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Random Walk: Examples
15
10
5
0
-5
-10
-15
10
20
30
40
50
60
70
80
90
100
102 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Random Walk with Drift: Examples
60
50
40
30
20
10
0
-10
10
20
30
40
50
60
70
80
90
100
103 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
EXAMPLE
Fun with Random Walks
Generate 50 different random walks
Plot all random walks
Try different variances and distributions
104 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
especially suitable for (short-run) forecasts
utilizes autocorrelations of lower order
1st order: correlations of successive observations
2nd order: correlations of observations with two periods in
between
Autoregressive model of order p
yt = α + β1 yt−1 + β2 yt−2 + . . . + βp yt−p + t
105 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
Number of machines produced by a firm
Year Units
2003
4
2004
3
2005
2
2006
3
2007
2
2008
2
2009
4
2010
6
⇒ Estimation of an AR model of order 2
yt = α + β1 yt−1 + β2 yt−2 + t
106 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
Estimation Table:
Year Constant
2003
1
2004
1
2005
1
2006
1
2007
1
2008
1
2009
1
2010
1
yt
4
3
2
3
2
2
4
6
yt−1
yt−2
4
3
2
3
2
2
4
4
3
2
3
2
2
⇒ OLS
ŷt = 3.5 + 0.8125yt−1 − 0.9375yt−2
107 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
Forecasting with an AR(2) model:
ŷt
= 3.5 + 0.8125yt−1 − 0.9375yt−2
y2011 = 3.5 + 0.8125y2010 − 0.9375y2009
= 3.5 + 0.8125 · 6 − 0.9375 · 4
= 4.625
108 / 442
Related documents