Upload
danghanh
View
266
Download
0
Embed Size (px)
Citation preview
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) introductionTime series CharacteristicsNecessity of (economic) forecastsComponents of time series dataSome simple filtersTrend extractionCyclical ComponentSeasonal ComponentIrregular ComponentSimple Linear Models
3 A more formal introduction
4 (Univariate) Linear ModelsNotation and TerminologyStationarity of ARMA ProcessesIdentification Tools
2 / 442
Univariate Time Series Analysis
5 Modeling ARIMA Processes: The Box-Jenkins ApproachEstimation of Identification FunctionsIdentificationEstimation
Yule-Walker EstimationLeast Squares EstimatorsMaximum Likelihood Estimator (MLE)
Model specificationDiagnostic Checking
6 PredictionSome TheoryExamplesForecasting in PracticeA second Case StudyForecasting with many predictors
7 Trends and Unit Roots3 / 442
Univariate Time Series Analysis
Stationarity vs. NonstationarityTesting for Unit Roots: Dickey-Fuller-TestTesting for Unit Roots: KPSS
8 Models for financial time seriesARCHGARCHGARCH: Extensions
4 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content I1 Organizational Details and Outline
2 An (unconventional) introductionTime series CharacteristicsNecessity of (economic) forecastsComponents of time series dataSome simple filtersTrend extractionCyclical ComponentSeasonal ComponentIrregular ComponentSimple Linear Models
3 A more formal introduction
4 (Univariate) Linear ModelsNotation and Terminology
5 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content IIStationarity of ARMA ProcessesIdentification Tools
5 Modeling ARIMA Processes: The Box-Jenkins ApproachEstimation of Identification FunctionsIdentificationEstimation
Yule-Walker EstimationLeast Squares EstimatorsMaximum Likelihood Estimator (MLE)
Model specificationDiagnostic Checking
6 PredictionSome TheoryExamplesForecasting in Practice
6 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Table of content IIIA second Case StudyForecasting with many predictors
7 Trends and Unit RootsStationarity vs. NonstationarityTesting for Unit Roots: Dickey-Fuller-TestTesting for Unit Roots: KPSS
8 Models for financial time seriesARCHGARCHGARCH: Extensions
7 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Introduction
Time series analysis:Focus: Univariate Time Series and Multivariate TimeSeries Analysis.A lot of theory and many empirical applications with realdataOrganization:
12.04. - 24.05.: Univariate Time Series Analysis, sixlectures (Klaus Wohlrabe)31.05. - End of Semester: Multivariate Time SeriesAnalysis (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 TimeSeries Analysis.A lot of theory and many empirical applications with realdataOrganization:
12.04. - 24.05.: Univariate Time Series Analysis, sixlectures (Klaus Wohlrabe)31.05. - End of Semester: Multivariate Time SeriesAnalysis (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 TimeSeries Analysis.A lot of theory and many empirical applications with realdataOrganization:
12.04. - 24.05.: Univariate Time Series Analysis, sixlectures (Klaus Wohlrabe)31.05. - End of Semester: Multivariate Time SeriesAnalysis (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 TimeSeries Analysis.A lot of theory and many empirical applications with realdataOrganization:
12.04. - 24.05.: Univariate Time Series Analysis, sixlectures (Klaus Wohlrabe)31.05. - End of Semester: Multivariate Time SeriesAnalysis (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: armaxgarchxScript is available at the day before the lecture (noon)All datasets and programme codesTutorial: Mixture between theory and R - Examples
9 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Literature
Shumway and Stoffer (2010): Time Series Analysis andIts Applications: With R ExamplesBox, Jenkins, Reinsel (2008): Time Series Analysis:Forecasting and ControlLütkepohl (2005): Applied Time Series Econometrics.Hamilton (1994): Time Series Analysis.Lütkepohl (2006): New Introduction to Multiple Time SeriesAnalysisChatham (2003): The Analysis of Time Series: AnIntroductionNeusser (2010): Zeitreihenanalyse in denWirtschaftswissenschaften
10 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Examination
Evidence of academic achievements: Two hour writtenexam both for the univariate and multivariate partSchedule for the Univariate Exam: 30/05 (to beconfirmed!!!)
11 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Prerequisites
Basic Knowledge (ideas) of OLS, maximum likelihoodestimation, heteroscedasticity, autocorrelation.Some algebra
12 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Software
Where you have to pay:STATAEviewsMatlab (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 thescript!)live demonstrations (examples) using Excel, Matlab,Eviews, Stata and JMultilive programming using Matlab
14 / 442
Univariate Time Series Analysis
Organizational Details and Outline
Outline
IntroductionLinear ModelsModeling ARIMA Processes: The Box-Jenkins ApproachPrediction (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 Follow-up QuestionsAll types of data
How are the variables de-fined?
What are the units of measurement? Do the data com-prise a sample? Ifo so, how was the sample drawn?
What is the relationship be-tween the data and the phe-nomenon of interest?
Are the variables direct measurements of the phe-nomenon of interest, proxies, correlates, etc.?
Who compiled the data? Is the data provider unbiased? Does the provider pos-sess the skills and resources to enure data quality andintegrity?
What processes generatedthe data?
What theory or theories can account for the relationshipsbetween the variables in the data?
Time Series dataWhat is the frequency ofmeasurement
Are the variables measured hourly, daily monthly, etc.?How are gaps in the data (for example, weekends andholidays) handled?
What is the type of mea-surement?
Are the data a snapshot at a point in time, an averageover time, a cumulative value over time, etc.?
Are the data seasonally ad-justed?
If so, what is the adjustment method? Does this methodintroduce artifacts in the reported series?
17 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content I1 Organizational Details and Outline
2 An (unconventional) introductionTime series CharacteristicsNecessity of (economic) forecastsComponents of time series dataSome simple filtersTrend extractionCyclical ComponentSeasonal ComponentIrregular ComponentSimple Linear Models
3 A more formal introduction
4 (Univariate) Linear ModelsNotation and Terminology
18 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content IIStationarity of ARMA ProcessesIdentification Tools
5 Modeling ARIMA Processes: The Box-Jenkins ApproachEstimation of Identification FunctionsIdentificationEstimation
Yule-Walker EstimationLeast Squares EstimatorsMaximum Likelihood Estimator (MLE)
Model specificationDiagnostic Checking
6 PredictionSome TheoryExamplesForecasting in Practice
19 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Table of content IIIA second Case StudyForecasting with many predictors
7 Trends and Unit RootsStationarity vs. NonstationarityTesting for Unit Roots: Dickey-Fuller-TestTesting for Unit Roots: KPSS
8 Models for financial time seriesARCHGARCHGARCH: 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 dynamicsnecessity of (economic) forecasts (for policy)time series decomposition (trends vs. cycle)smoothing of time series (filtering out noise)
moving averagesexponential 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 atdate 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 I80
8590
9510
010
5G
DP
1990q1 1995q1 2000q1 2005q1 2010q1 2015q1time
Germany: GDP (seasonal and workday-adjusted, Chain index)
24 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: GDP II-4
-20
2Q
uart
erly
GD
P g
row
th
1990q1 1995q1 2000q1 2005q1 2010q1 2015q1time
Germany: Quarterly GDP growth
-10
-50
5Y
early
GD
P g
row
th
1990q1 1995q1 2000q1 2005q1 2010q1 2015q1time
Germany: Yearly GDP growth
25 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Retail Sales0
5010
015
0R
etai
l Sal
es -
Cha
in In
dex
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1time
Germany: Retail Sales - non-seasonal adjusted
26 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Industrial Production20
4060
8010
012
0IP
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1time
Germany: Industrial Production (non-seasonal adjusted, Chain index)
27 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Industrial Production-2
0-1
00
1020
30M
onth
ly IP
gro
wth
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1time
Germany: Monthly IP growth
-40
-20
020
40Y
early
IP g
row
th
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1time
Germany: Yearly GIP growth
28 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: The German DAX0
5000
1000
015
000
DA
X
0 2000 4000 6000 8000Time
Level
-.06
-.04
-.02
0.0
2.0
4R
etur
n
0 2000 4000 6000 8000Time
Return
29 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Economic Time Series: Gold Price0
500
1000
1500
2000
Gol
d
0 2000 4000 6000 8000 10000Time
Level
-.1
-.05
0.0
5R
etur
n
0 2000 4000 6000 8000 10000Time
Return
30 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Further Time Series: Sunspots0
5010
015
020
0S
unsp
ots
1700 1800 1900 2000time
31 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Further Time Series: ECG4
4.5
55.
56
EC
G
0 2000 4000 6000 8000 10000Time
32 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Further Time Series: Simulated Series: AR(1)-2
-10
12
3A
R
0 20 40 60 80 100Time 33 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Further Time Series: Chaos or a real time series?-1
0-5
05
1990m1 1995m1 2000m1 2005m1 2010m1 2015m1time 34 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Further Time Series: Chaos?-4
-20
24
0 20 40 60 80 100Time 35 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Time series Characteristics
Characteristics of Time series
TrendsPeriodicity (cyclicality)SeasonalityVolatility ClusteringNonlinearitiesChaos
36 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Necessity of (economic) forecasts
Necessity of (economic) Forecasts
For political actions and budget control governments needforecasts for macroeconomic variablesGDP, interest rates, unemployment rate, tax revenues etc.marketing need forecasts for sales related variables
future salesproduct 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 optimizewarehousing and employment of stafffirms need to forecasts cash-flows in order to account ofilliquidity phases or insolvencyuniversity administrations needs forecasts of the number ofstudents for calculation of student fees, staff planning,space organizationmigration flowshouse prices
38 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Components of time series data
Time series decomposition
Time Series
Trend Cyclical
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 overtime)ct cyclical component (deterministic, periodic, mediumterm horizons)st seasonal component (deterministic, periodic; more thanone 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 forheteroscedasticity (e.g. log-transformation to stabilizeseasonal 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)
At a later stage:
series = model + errors (5)
⇒ mathematical function plus a probability distribution ofthe 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 ) bythe linear operation
yt =+s∑
r=−q
ar xt+r
where ar is a set of weights. In order to smooth local fluctuationone should chose the weight such that∑
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 closein time to ti . One possible smoother ist
y∗ti = 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/N2.The smoother is characterized by
span, the number of adjacent points included in thecalculationtype 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 includedperiods to calculate the mean).In order to smooth the cyclical component, L shouldexceed the cycle lengthL should be uneven (avoids another cyclical component)
46 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Moving Average
MA(yt ) =1
2q + 1
+q∑r=−q
yt+r
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 PeriodsFirst MA term: MA2(3) = y1+y2+y3
3
Second MA term: MA3(3) = y2+y3+y43
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
0
20
40
60
80
100
120
140
50 55 60 65 70 75 80 85 90 95 00 05 10
IP
0
20
40
60
80
100
120
140
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(3)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(5)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(7)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(9)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(11)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(25)
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(51)
20
30
40
50
60
70
80
90
100
110
50 55 60 65 70 75 80 85 90 95 00 05 10
M A(101)
⇒ the larger L the smoother and shorter the filtered series50 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
EXAMPLE
Generate a random time series (normally distributed) withT = 20
Quick and dirty: Moving Average with ExcelNice and Slow: Write a simple Matlab program forcalculating a moving average of order LAdditional Task: Increase the number of observations toT = 100, include a linear time trend and calculate differentMAsVariation: Include some outliers and see how thecalculations change.
51 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
weighted moving averageslatest observation has the highest weight compared to theprevious periods
yt = wyt + (1− w)yt−1
Repeated substitution gives:
yt = wt−1∑s=0
(1− w)syt−s
⇒ that’s why it is called exponential smoothing, forecasts arethe weighted average of past observations where the weightsdecline exponentially with time.
52 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
Is used for smoothing and short–term forecastingChoice of w :
subjective or through calibrationnumbers between 0 and 1Close to 0 for smoothing out unpleasant cyclical or irregularcomponentsClose to 1 for forecasting
53 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
yt = wyt + (1− w)yt−1 w = 0.2
54 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Some simple filters
Exponential Smoothing
0
20
40
60
80
100
120
140
50 55 60 65 70 75 80 85 90 95 00 05 10
IP
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
w=0.05
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
w=0.2
0
20
40
60
80
100
120
140
50 55 60 65 70 75 80 85 90 95 00 05 10
w=0.95
55 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Trend Component
positive or negative trendobserved over a longer time horizonlinear vs. non–linear trendsmooth vs. non–smooth trends⇒ trend is ’unobserved’ in reality
56 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Trend Component: Example
0
4
8
12
16
20
24
25 50 75 100 125 150 175 200
Linear trend with a cyclical component
0.0
0.5
1.0
1.5
2.0
2.5
3.0
25 50 75 100 125 150 175 200
Nonlinear trend with cyclical component
57 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Why is trend extraction so important?
The case of detrending GDPtrend GDP is denoted as potential outputThe difference between trend and actual GDP is called theoutput gapIs an economy below or above the current trend? (Or is theoutput 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 Time (xt ) Turnover (yt )05 1 206 2 507 3 208 4 209 5 710 6 6
yt = α + βxt
59 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Linear Trend Model
Estimation with OLS
yt = α + βxt = 1.4 + 0.743xt
Forecast for 2011:
y2011 = 1.4 + 0.743 · 7 = 6.6
60 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Quadratic Trend Model
Year Time (xt ) Time2 (x2t ) Turnover (yt )
05 1 1 206 2 4 507 3 9 208 4 16 209 5 25 710 6 36 6
yt = α + β1xt + β2x2t
61 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Quadratic Trend Model
yt = α + βxt + β2x2t = 3.4− 0.757143xt + 0.214286x2
t
Forecast for 2011:
y2011 = 3.4− 0.757143 · 7 + 0.214286 · 72 = 8.6
62 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Exponential Trend ModelYear Time (xt ) Turnover (yt )05 1 206 2 507 3 208 4 209 5 710 6 6
yt = αβxt1
⇒ Non-linear Least Squares (NLS) orLinearize the model and use OLS:
log yt = logα + log(β1)xt
⇒ ’relog’ the model63 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Exponential Trend Model
Estimation via NLS:
yt = α + β1xt
= 0.08 · 1.93xt
Forecast for 2011:
y2011 = 0.08 · 1.937 = 15.4
64 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Logarithmic Trend Model
Year Time (xt ) log(Time) Turnover (yt )05 1 log(1) 206 2 log(2) 507 3 log(3) 208 4 log(4) 209 5 log(5) 710 6 log(6) 6
Logarithmic Trend:yt = α + β1 log xt
65 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Logarithmic Trend Model
Estimation via OLS:
yt = α + β1 log xt = 1.934675 + 1.883489 · log yt
Forecast for 2011:
Y2011 = 1.934675 + 1.883489 · log(7) = 5.6
66 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Comparison of different trend models
1
2
3
4
5
6
7
8
2005 2006 2007 2008 2009 2010
TURNOVER Linear TrendLogarithmic Trend Quadratic TrendExponential Trend
67 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Detrending GDP
60
70
80
90
100
110
120
92 94 96 98 00 02 04 06 08 10 12
GDP Linear TrendLogarithmic 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 stationaryQuadratic trend model, if the second differences
(yt − yt−1)− (yt−1 − yt−2)
are stationaryLogarithmic trend model, if the relative differences
yt − yt−1
yt
are stationary69 / 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
minµt
T∑t=1
[(yt − µt )2 + λ
T−1∑t=2
{(µt+1 − µt )− (µt − µt−1)}2] (8)
where µt is the flexible trend and λ a smoothness parameterchosen 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 data1600 for quarterly data14400 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)
76
80
84
88
92
96
100
104
108
112
92 94 96 98 00 02 04 06 08 10 12
IP Lambda = 14,400Lambda a.t. Ravn and Uhlig (2002) Lambda = 50,000Lambda = 10,000,000
72 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
The Hodrick-Prescott-Filter (HP)
-16
-12
-8
-4
0
4
8
12
92 94 96 98 00 02 04 06 08 10 12
Lambda = 14,400 Lambda a.t. Ravn and Uhlig (2002)Lambda = 50,000 Lambda = 10,000,000
73 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Problems with the HP-Filter
λ is a ’tuning’ parameterend 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
8590
9510
010
5G
DP
1990q1 1995q1 2000q1 2005q1 2010q1 2015q1time
Germany: GDP (seasonal and workday-adjusted, Chain index)
75 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
HP-Filter
-6
-4
-2
0
2
4
75
80
85
90
95
100
105
110
92 94 96 98 00 02 04 06 08 10 12 14
GDP Trend Cycle
Hodrick-Prescott Filter (lambda=1600)
76 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Trend extraction
Can we test for a trend?
Yes and noIf the trend component significant?several trends can be significantTrend might be spuriousIs it plausible that there is a trend?A priori information by the researcherunit 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 adjustmentmight be appropriatePrepare your data set in Excel and estimate various trendsin EviewsWhich trend would you choose?
78 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component
is not always present in time seriesIs the difference between the observed time series and theestimated trend
In economicscharacterizes the Business cycledifferent length of cycles (3-5 or 10-15 years)
79 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component: Example
-15
-10
-5
0
5
10
70
80
90
100
110
120
92 94 96 98 00 02 04 06 08 10 12 14
IP Trend Cycle
Hodrick-Prescott Filter (lambda=14400)
80 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component: Example II0
5010
015
020
0S
unsp
ots
1700 1800 1900 2000time
81 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Cyclical Component: Example III4
4.5
55.
56
EC
G
0 2000 4000 6000 8000 10000Time
82 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Cyclical Component
Can we test for a cyclical component?
Yes and nosee the trend sectionDoes a cycle make sense?
83 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Componentsimilar upswings and downswings in a fixed time intervalregular pattern, i.e. over a year
050
100
150
Ret
ail S
ales
- C
hain
Inde
x
1950m1 1960m1 1970m1 1980m1 1990m1 2000m1 2010m1time
Germany: Retail Sales - non-seasonal adjusted
84 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Types of Seasonality
A: yt = mt + St + εt
B: yt = mtSt + εt
C: yt = mtStεt
Model A is additive seasonal, Models B and C containsmultiplicative 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 thelogarithmic transformation to make the effect additive
86 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal AdjustmentSimplest 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 adjustedExample: Monthly data
yt =12∑
i=1
βiDi + εt
εt = yt −12∑
i=1
βDi
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
-10
-5
0
5
10
15
80
90
100
110
120
130
140
1992 1994 1996 1998 2000 2002 2004 2006 2008
Residual Actual Fitted
88 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Adjustment: Example
90
95
100
105
110
115
92 94 96 98 00 02 04 06 08 10
Dummy Approach
92
96
100
104
108
112
92 94 96 98 00 02 04 06 08 10
Arima X12
80
90
100
110
120
130
140
92 94 96 98 00 02 04 06 08 10
Original Series
Seasonal Adjustement Retail Sales
89 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Moving Averages
For monthly data one can employ the filter
SMA(yt ) =12yt−6 + yt−5 + yt−4 + . . .+ yt+6 + 1
2yt+6
12
or for quarterly data
SMA(yt ) =12yt−2 + yt−1 + yt + yt+1 + 1
2yt+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
0
20
40
60
80
100
120
50 55 60 65 70 75 80 85 90 95 00 05 10
Moving Seasonal Average Dummy Approach91 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Differencing
seasonal effect can be eliminated using the a simple linearfilterin case of a monthly time series: ∆12yt = yt − yt−12
in case of a quarterly time series: ∆4yt = yt − yt−4
92 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Seasonal Differencing: Retail Sales Example
-12
-8
-4
0
4
8
12
16
50 55 60 65 70 75 80 85 90 95 00 05 10
Year Differenced
-50
-40
-30
-20
-10
0
10
20
30
50 55 60 65 70 75 80 85 90 95 00 05 10
Differenced Month
93 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
Can we test for seasonality?
Yes and noDoes seasonality makes sense?Compare the seasonal adjusted and unadjusted serieslook into the ARIMA X12 outputBe aware of changing seasonal patterns
94 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Seasonal Component
EXAMPLE
Time series: seasonally unadjusted Industrial Production inGermany (1950:01-2011:02)
Remove the seasonality by a moving seasonal filterTry the dummy approachFinally, use the ARIMAX12-ApproachStart the sample in 1991:01 and compare all filters with thefull sample
95 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Irregular Component
Irregular Component
erratic, non-systematic, random "residual" fluctuations dueto random shocks
in naturedue to human behavior
no observable iterations
96 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Irregular Component
Can we test for an irregular component?
YESseveral tests available whether the irregular component isa 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
-4
-2
0
2
4
10 20 30 40 50 60 70 80 90 100-4
-2
0
2
4
10 20 30 40 50 60 70 80 90 100-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100
-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100
-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100-4
-2
0
2
4
10 20 30 40 50 60 70 80 90 100-3
-2
-1
0
1
2
3
10 20 30 40 50 60 70 80 90 100
White Noise with Variance = 1
99 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
White Noise
-3
-2
-1
0
1
2
10 20 30 40 50 60 70 80 90 100
WN with Variance = 1
-6
-4
-2
0
2
4
6
10 20 30 40 50 60 70 80 90 100
White Noise with Variance = 2
-30
-20
-10
0
10
20
30
10 20 30 40 50 60 70 80 90 100
White Noise with Variance = 10
-400
-300
-200
-100
0
100
200
300
10 20 30 40 50 60 70 80 90 100
White Noise with Variance = 100
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∑
j=1
εj
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
-10
0
10
20
30
40
50
60
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 WalksGenerate 50 different random walksPlot all random walksTry different variances and distributions
104 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
especially suitable for (short-run) forecastsutilizes autocorrelations of lower order
1st order: correlations of successive observations2nd order: correlations of observations with two periods inbetween
Autoregressive model of order p
yt = α + β1yt−1 + β2yt−2 + . . .+ βpyt−p + εt
105 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processesNumber of machines produced by a firm
Year Units2003 42004 32005 22006 32007 22008 22009 42010 6
⇒ Estimation of an AR model of order 2
yt = α + β1yt−1 + β2yt−2 + εt
106 / 442
Univariate Time Series Analysis
An (unconventional) introduction
Simple Linear Models
Autoregressive processes
Estimation Table:Year Constant yt yt−1 yt−22003 1 42004 1 3 42005 1 2 3 42006 1 3 2 32007 1 2 3 22008 1 2 2 32009 1 4 2 22010 1 6 4 2
⇒ OLSyt = 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:
yt = 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