Topic 8: Time Series & Forecasting
Vincent (2022) Lecture 11
Camn et al (2016), Chapter 8
Three main goals
COMPONENTS IN TIME FORECASTING STATIONARY FORECASTING TIME SERIES
SERIES DATA TIME SERIES WITH SEASONAL EFFECTS
Forecasting Techniques
• Businesses require good forecasts of future events.
• There are a wide range of forecasting techniques.
• Three major categories of forecasting approaches:
1. Qualitative and judgmental techniques
2. Statistical time-series models
3. Explanatory/causal models
Qualitative and Judgmental Forecasting
• Qualitative and Judgmental techniques rely on experience and
intuition.
• They are necessary when historical data is not available.
• The Delphi method (the estimate-talk-estimate technique (ETE))
questions an anonymous panel of experts 2-3 times in order to reach
a convergence of opinion on the forecasted variable.
Statistical Forecasting Models
• Time Series - a stream of historical data, such as weekly sales
◦ T periods, t = 1, 2, …, T
• Often you can plot the time series data to observe a trend - a gradual upward or
downward movement of a time series.
• Time series generally have components such as:
◦ random behaviour
◦ trends (upward or downward)
◦ seasonal effects
◦ cyclical effects
• Stationary time series have only random behaviour.
Time series patterns
• Horizontal pattern (Stationary time series)
• Trend pattern
• Trend and seasonal pattern
• Cyclical pattern
Horizontal pattern
• A horizontal pattern exists when the data fluctuate randomly around a
constant mean over time.
• The term stationary time series is used to denote a time series whose
statistical properties are independent of time. In particular this means that:
1. The process generating the data has a constant mean.
2. The variability of the time series is constant over time.
• A time series plot for a stationary time series will always exhibit a
horizontal pattern with random fluctuations.
Trend effects
• General upward trend with some
short downward trends.
• Trend pattern exists when a time
series may also show gradual
shifts or movements to relatively
higher or lower values over a
longer period of time.
Seasonal and cyclical effects
A seasonal effect is one that repeats at Cyclical effects describe ups and down over a
fixed intervals of time, typically a year, much longer time frame, such as several
month, week, or day. years.
Seasonality with trend
Use the following diagrams
• Identify which series has
◦ Trend effects
◦ Seasonal effects
◦ Cyclical effects
• Which series are “stationary”?
• Data Source: (a) Google stock price for 200 consecutive days; (b) Daily change in the Google
stock price for 200 consecutive days; (c) Annual number of strikes in the US; (d) Monthly sales of
new one-family houses sold in the US; (e) Annual price of a dozen eggs in the US (constant
dollars); (f) Monthly total of pigs slaughtered in Victoria, Australia; (g) Annual total of lynx trapped
in the McKenzie River district of north-west Canada; (h) Monthly Australian beer production; (i)
Monthly Australian electricity production. (https://otexts.com/fpp2/stationarity.html)
Trends over different periods
Trend
Cyclicality
Trend
Trends over different periods
Trend
Cyclicality Seasonality & Cyclicality
Practice- Check the pattern
Bicycle Data
Cholesterol Data
SmartPhoneSales Data
Umbrella Data
Stationary series
• If yt is a stationary time series, then for all s, the distribution
of (yt,…,yt+s) does not depend on t.
• So, a stationary time series is one whose properties do not depend
on the time at which the series is observed.
• Time series with trends, or with seasonality or cyclicality are not
stationary — the trend, seasonality, and cyclicality will affect the
value of the time series at different times.
Forecasting Models for Stationary Time Series
• Moving average models
• Exponential smoothing models
◦ These are useful over short time periods when trend, seasonal, or cyclical
effects are not significant.
Moving Average Models
• The simple moving average method is a smoothing method based on
the idea of averaging random fluctuations in the time series to identify
the underlying direction in which the time series is changing.
• The simple moving average forecast for the next period is computed
as the average of the most recent k observations.
At At 1 At k 1
Ft 1
k
• Larger values of k result in smoother forecast models since extreme
values have less impact.
Example 8.1
• The Tablet Computer Sales file
contains the number of units
sold over the past 17 weeks.
• Three-period moving average
forecast for week 18:
A17 A16 A15 82 71 50
F18 67.67
3 3
Excel using Data Analysis add-in
How to improve forecasting?
• Naturally you can try different set of periods in moving average forecasting, then
you can compare them. To compare, we need some error metrics.
• These include mean absolute deviation (MAD), mean square error (MSE), Root
mean square error (RMSE) and Mean absolute percentage error (MAPE)
n
At Ft 2
n
At Ft
MAD t 1 9.2 MSE t 1 9.3
n n
n At Ft
n
At Ft 2 t 1 At
RMSE t 1
9.4 MAPE 100 9.5
n n
Example 8.2 using tablet computer sale data
• 2-, 3-, and 4-period moving average models
• 2-period model has lowest error metric values.
Exponential Smoothing Models
• Simple exponential smoothing models Ft 1 1 Ft At
Ft At Ft
• Where Ft+1 is the forecast for time period t+1, Ft is the forecast for
period t, At is the observed value in period t and alpha is a constant
between 0 and 1 called the smoothing constant.
• To begin set F1 and F2 equal to the actual observation in the period 1.
Example 8.3
• Forecast for week
3 when alpha =
0.7
0.7 : 1 0.7 88 0.7 44 57.2
• We can vary the
values of alpha,
then compare
metrics to choose.
Excel using Data Analysis
• Select Data Analysis from the Analysis
group and then choose Exponential
Smoothing.
• Note that Damping factor = 1−α
• The first cell of the Output Range should be
adjacent to the first data point.
Forecasting Models for Time Series with
a Linear Trend
Ft k at bt k
• The forecast for k periods into the future is a function of the level at
and the trend bt
• The models differ in their computations of at and bt
• Regression-based models could be appropriate for time series with a
linear trend and no significant seasonal component.
Regression-Based Forecasting for Time
Series with a Linear Trend
• Example Coal Production data with
a linear trendline
• Note that the linear model does not
adequately predict the recent drop
in production after 2008.
Autocorrelation
• An important assumption for using regression
analysis is the lack of autocorrelation among the
data.
• When autocorrelation is present, successive
observations are correlated with one another.
• For example, large observations tend to follow other
large observations, and small observations also tend
to follow one another.
• We can use residual plot to assess this.
• In such cases, other approaches, called
autoregressive models, are more appropriate.
Forecasting Time Series with Seasonality
• When time series exhibit seasonality, different techniques provide
better forecasts than the ones we have described:
◦ Multiple regression models with categorical variables for the seasonal
components
• Seasonality without trend
• Seasonality with trend
Regression Forecasting with Causal
Variables
• In many forecasting applications, other independent variables
besides time, such as economic indexes or demographic factors,
may influence the time series.
• Explanatory/causal models seek to identify factors that explain
statistically the patterns observed in the variable being forecast,
usually with regression analysis.
The Practice of Forecasting
• Judgmental and qualitative methods are used for forecasting sales
of product lines and broad company and industry forecasts.
• Simple time-series models are used for short- and medium-range
forecasts.
• Regression methods are typically used for long-term forecasts.
Sum-ups
• We have covered some basic modelling approaches to forecast future values of a time
series.
• Understanding different components in any time series is very crucial to choose
appropriate modelling approaches.
• For stationary time series: Moving average & Exponential smoothing models
• For time series with trend: Regression-based models
• For time series with seasonality: regression-based models with seasonal dummies.
• We also cover some criteria (metric) that we can use to compare the performance of
those models.
Practice- Forecasting
Bicycle Data: forecast bicycles sales for the next one/two/three years.
SmartPhoneSales Data: forecast smartphone sales for the next year.
Umbrella Data: forecast umbrella sales for the next year.
Armand Data: how to forecast sales of Armand’s Pizza Parlors