Applied Quantitative Research Methods
Time series
2nd March 2020
University of Bristol
1
Time Series
Dr Marion Prat
[Link]@[Link]
Office: 25-27 Belgrave Road, room 2.01
Advice and feedback hours:
Tuesday: 10:30-11:30 and Thursday 13:30-14:30
2
Time series
Plan of today’s lecture:
Forecasting:
7. Forecasting concepts [Diebold: Chapter 5.1-5.2]
8. Modeling seasonality [Diebold: Chapter 6]
Textbook: Diebold, F.X., Elements of Forecasting, 4th Ed
3
6. Models for the trend
Yt = Tt + ut
Linear trend
Tt = B0 + B1 × Timet (1)
where Timet is the time trend.
Quadratic trend
Tt = B0 + B1 × Timet + B2 × Timet2 (2)
Exponential trend
Tt = B0 × e B1 Timet
ln(Yt ) = ln(Tt ) + vt = B0∗ + B1 Timet + vt (3)
4
6. Models for the trend
Example: US E-commerce retail sales ($ billions)
5
6. Models for the trend
Example: US E-commerce retail sales ($ billions)
Estimation results (OLS)
Linear Quadratic
Time 1.53 -0.11
(0.05) (0.08)
Time 2 - 0.02
- (0.00)
const -11.48 10.06
(2.32) (1.28)
SER 10.06 3.62
Note: Standard errors are in bracket. SER is the standard error of the regression.
Which model should we select?
6
7. Forecasting concepts
Example: US E-commerce retail sales ($ billions)
date esales Time Time 2
1999-Q4 4.48 1 1
2000-Q1 5.69 2 4
... ... ... ...
2018-Q2 126.98 75 5625
2018-Q3 130.22 76 5776
2018-Q4 132.83 77 5929
Estimated linear trend model:
\ t = −11.48 + 1.53 × Timet
esales
Given this model and observed sales in 2018Q4, what is the e-sales
forecast in 2019Q1? 2019Q2?
7
7. Forecasting concepts
Example: US E-commerce retail sales ($ billions)
\ t = −11.48 + 1.53 × Timet
esales
Forecasting sales in 2019Q1 (1-quarter ahead):
esales2019Q1 = −11.48 + 1.53 × Time2019Q1
where Time2019Q1 is perfectly predictable and equal to 78.
esales2019Q1 = −11.48 + 1.53 × 78 = 107.86
The prediction that e-commerce sales in the US in 2019Q1 will be $107.86
billions using information up to 2018Q4 is a point forecast.
A point forecast is a single number.
8
7. Forecasting concepts
Example: US E-commerce retail sales ($ billions)
9
7. Forecasting concepts
Consider the linear trend model
Yt = B0 + B1 × Timet + ut
Standard deviation of the error term σ:
s
PT 2
t=1 ut
σ=
T −k
T is the number of observations in the sample.
k is the number of estimated parameters.
What information does it give us?
σ tells us the average magnitude of the error term / forecast error.
10
7. Forecasting concepts
Standard error of the regression (σ̂): Estimate of the standard
deviation of error term
Ŷt = b0 + b1 × Timet [Predicted Y]
se(b0 ) se(b1 )
et = Yt − Ŷt [Estimated error term]
s
PT 2
r
t=1 et RSS
σ̂ = = [SER]
T −k T −k
T is the number of observations in the sample.
kPis the number of estimated parameters.
T 2
t=1 et is the residual sum of squares (RSS).
11
7. Forecasting concepts
Consider the linear trend model
Yt = B0 + B1 × Timet + ut
We have data up to period T (T observations)
Forecast h period ahead using information up to time T:
YT +h,T = B0 + B1 × TimeT +h,T + uT +h,T
where
h is the forecast horizon: the number of periods between today and
the date of the forecast
Timet+h is perfectly predictable and equal to T + h
12
7. Forecasting concepts
Assumption 1: The error term ut is an non-autocorrelated
(cov (ut , ut−j ) = 0) zero-mean series with constant variance (σ 2 )
A white noise series
Assumption 2: ut is normally distributed.
13
7. Forecasting concepts
YT +h,T = B0 + B1 × TimeT +h,T + uT +h,T
If Assumption 1 holds, then:
ut+h is expected to be 0
The optimal point forecast for YT +h at time T is:
ET (YT +h ) = B0 + B1 × TimeT +h
= expectation of YT +h conditional on information at time T.
Estimated point forecast:
ŶT +h,T = b0 + b1 × TimeT +h
14
7. Forecasting concepts
Interval forecast: range of values is which we expect the realized value of
the series to fall with some probability.
If Assumption 2 holds, then a 95% interval forecast can be constructed
as:
[ET (YT +h ) − 1.96σ, ET (YT +h ) + 1.96σ]
ET (YT +h ) ± 1.96σ
where σ is the standard deviation of the error term.
Estimated 95% interval forecast:
ŶT +h,T ± 1.96σ̂
where σ̂ is the standard error of the regression.
15
7. Forecasting concepts
Example: US E-commerce retail sales ($ billions)
\ t = −11.48 + 1.53 × Timet
esales σ̂ = 10.06
Point forecast for 2019Q1:
esales2019Q1 = −11.48 + 1.53 × 78 = 107.86
95% interval forecast for the forecast of e-commerce sales in 2019Q1:
[107.86 − 1.96 × 10.06, 107.86 + 1.96 × 10.06]
[88.14, 127.58]
There is a 95% probability that e-commerce sales will be between $88.14
and $127.58 billions.
16
7. Forecasting concepts
How do we select among the different trend models?
Consider the linear trend model again
Yt = B0 + B1 × Timet + ut
One-step ahead forecast:
ŶT +1,T = b0 + b1 × TimeT +1
One-step ahead forecast error: eT +1,T = YT +1 − ŶT +1,T
→ Minimize the average forecast error
→ Minimize the out-of-sample one-step ahead forecast error variance
17
7. Forecasting concepts
How do we select among the different trend models?
Example: US E-commerce retail sales ($ billions)
18
7. Forecasting concepts
How do we select among the different trend models?
An estimate of the out-of-sample one-step ahead mean-squared forecast
error variance is the in-sample mean-squared error (MSE).
The MSE is defined as:
PT 2
t=1 et RSS
MSE = =
T T
where
et is the estimated error using data up to T.
PT 2
t=1 et is the residual sum of squares (RSS).
19
7. Forecasting concepts
How do we select among the different trend models?
Problem: MSE falls continuously as more variables are added to the
model because the OLS estimates are those that minimize RSS.
Solution: penalize RSS each time we add an additional regressor using
either of these criteria: PT 2
2k
t=1 et
AIC = e T
T
PT
k e2
SIC = T T t=1 t
T
PT
where k is the number of regressors and t=1 et2 is the residual sum of
squares.
→ Select the models that minimize either the AIC or the SIC.
20
7. Forecasting concepts
How do we select among the different trend models?
Example: US E-commerce retail sales ($ billions)
Model selection criteria: AIC and SIC
Linear Quadratic
AIC 576.06 420.82
SIC 580.75 427.85
AIC: 420.82 < 576.06
SIC: 427.85 < 580.75
→ Both AIC and SIC select the quadratic trend model.
21
8. Modeling seasonality
Central England Temperature in ◦ C (Met Office), daily
A seasonal pattern is one that repeats itself every year.
When the annual repetition is exact, we speak of deterministic
seasonality. Seasonality can also be stochastic, in which case there is an
element of randomness in the return of the seasonal pattern.
22
8. Modeling seasonality
Any technology involving the weather (agricultural commodities, outdoor
work,...) is likely to be seasonal.
Example: New housing starts in the US (thousands of units)
Jan 1959 - Jan 2019 Jan 2015 - Jan 2018
23
8. Modeling seasonality
Preferences may also be linked to the calendar.
Example: Ice cream consumption, hospital admissions,...
Social institutions that are linked to the calendar such as holidays
are responsible for seasonal variation in a variety of series.
Example: E-commerce sales, tourism,...
Ice cream production, US (2012=100) E-commerce sales, US ($ billions)
24
8. Modeling seasonality
Regression on seasonal dummies:
Let s be the number of seasons in a year.
We think of s as the number of observations we observe each year for
a given time series
Quarterly data: s = 4
Monthly data: s = 12
Weekly data: s = 52
Construct seasonal dummy variables indicating in which season
each observation belongs to.
25
8. Modeling seasonality
With quarterly data. Then you would create 4 seasonal dummies as
follows:
D1 = 1 if we are in the first quarter and 0 otherwise
D2 = 1 if we are in the second quarter and 0 otherwise
D3 = 1 if we are in the third quarter and 0 otherwise
D4 = 1 if we are in the fourth quarter and 0 otherwise
Monthly data: construct 12 monthly dummies.
Daily data: construct 7 daily dummies.
26
8. Modeling seasonality
Pure seasonal dummy model:
s
X
Yt = Ci Dit + ut
i=1
Quarterly data:
Yt = C1 D1t + C2 D2t + C3 D3t + C4 D4t + ut
Monthly data:
Yt = C1 D1t + C2 D2t + ... + C12 D12t + ut
The Ci coefficients are the seasonal factors.
We are effectively allowing for a different intercept for each season.
Note how we did not include an intercept in this specification. Beware the
perfect multicollinearity / dummy variable trap!
27
8. Modeling seasonality
HSt = C1 D1t + C2 D2t + ... + C12 D12t + ut
28
8. Modeling seasonality
Dummy variables can be included to account for:
Holidays:
Example: Easter weekend is an important determinant of sales or
tourism.
→ Create a dummy variable equal to 1 if the holiday falls in the
current month and 0 otherwise (monthly data).
One-time events may affect the trend of a time series
Example: the ash cloud from an icelandic volcano severely affected air
passenger traffic for about 10 days in May and April 2010.
→ Create a dummy variable equal to 1 each of the affected days and
zero otherwise (daily data)
29
8. Modeling seasonality
Full model:
s
X v
X
Yt = B1 Tt + Ci Dit + γi EVit + ut
i=1 i=1
where
Tt is a deterministic time trend (which may also be nonlinear)
Ds are seasonal dummies
EV s are holiday/event dummies. To include v different
holidays/events, we need to include v dummies.
30