Professional Documents
Culture Documents
Chapter 6
Time Series and Forecasting
Objectives
After completing this chapter, you can:
• Describe the trend, cyclical, seasonal, and irregular components of the
time series model.
• Smooth a time series with the moving average and exponential smoothing
techniques.
• Fit a linear or nonlinear trend equation to a time series.
• Determine seasonal indexes and use them to compensate for the
seasonal effects in a time series.
• Use the forecast methods to estimate a future value.
• Use forecast accuracy to compare how well equations fit data.
1
8/11/2022
Outline
• Time series & its components
• Smoothing methods
• Finding the trend
• Finding Seasonal variation
• Forecasting
2
8/11/2022
3
8/11/2022
4
8/11/2022
Classical Decomposition
• One method of describing a time series
• Decompose the series into various components: Trend, Seasonal effects,
Cycles and Irregular
• Our aim is to understand and identify different variations so that we can
easily predict the future variations separately and combine together
• Look how the above complicated series could be understood as follows
separately
Time
Series
10
5
8/11/2022
Trend Component
• Trend: the long-term patterns or movements in the data.
• Overall or persistent, long-term upward or downward pattern of movement.
• Due to long-term factors such as changes in the population,
demographics, technology, or consumer preferences
Sales
Time
11
Trend Component
• Trend can be upward or downward
• Trend can be linear or non-linear
Sales Sales
Time Time
Downward linear trend Upward nonlinear trend
12
6
8/11/2022
Seasonal Component
• Short-term regular wave-like patterns
• Observed within 1 year
• Often monthly or quarterly
• Due to weather, customs, seasons in the year or particular patterns during
a month, a week, or a day
• E.g. Consumption of heating oil, which is high in winter, and low in
other seasons of year.
• Gasoline consumption, which is high in summer when most people go
on vacation.
13
Seasonal Component
Year n+1
Sales Year n
Summer
Winter
Summer
Winter Spring Fall
Spring Fall
Time (Quarterly)
14
7
8/11/2022
Cyclical Component
• Long-term wave-like patterns
• Regularly occur but may vary in length
• Often measured peak to peak or trough to trough
• Due to interaction of factors influencing economy
• E.g. Business cycle of some 8 to 10 years between period of “Boom”
and “Bust” in modern industrialised economies
• Financial crisis or economic crisis is around 20 to 30 years
15
Cyclical Component
1 Cycle
Sales
Year
16
8
8/11/2022
Irregular Component
• Unpredictable, random, “residual” fluctuations
• Due to random variations of:
• Nature (earthquake, tsunami…)
• Accidents or unusual events (union strike…)
• Short duration & nonrepeating
• Makes it difficult to detect the pattern of other components in a time series
(“noise” in the time series)
→ One of the tasks in time series analysis is to eliminate random variation
out of a time series
17
18
9
8/11/2022
19
Y Y
t t
20
10
8/11/2022
21
22
11
8/11/2022
20
Sales ($ Millions)
15
10
0
0 2 4 6 8 10 12 14
Week
23
Smoothing methods
• Smoothing methods dampen the impacts of fluctuation in a time series,
thereby providing a better view of the trend and (possibly) the cyclical
components. Used with Horizontal pattern, include:
• Moving Averages
• Exponential Smoothing
• They are called smoothing methods because their objective is to smooth
out the random fluctuations in the time series.
• They are most appropriate for short-range forecasts.
24
12
8/11/2022
Moving Averages
• Moving Averages (MA) is one of the smoothing methods
• Series of arithmetic means of the values of a fixed number of consecutive
time periods
• Used only for smoothing provide overall impression of data over time
• Reduce/eliminate random variations or reveal the trend of a time series
25
Moving Averages
• We can choose any number of periods with which to calculate MA,
depending on our objectives
• Result depends upon choice of k (length of period for computing means)
• Examples:
• For a 3-year moving average, k = 3
• For a 5-year moving average, k = 5
• Etc.
26
13
8/11/2022
Moving Averages
• Second average:
x x x x x
MA
5
• etc.
27
30
6 48
7 33 20
8 37 10
9 37 0
10 50 1 2 3 4 5 6 7 8 9 10 11
11 40 Year
etc… etc…
28
14
8/11/2022
60
• The 5-year moving 50
average smoothes 40
Sales
30
the data and shows
20
the underlying
10
trend 0
1 2 3 4 5 6 7 8 9 10 11
Year
30
15
8/11/2022
Moving Averages
• Even number of points
• We need even numbered MA s for seasonal adjustments, e.g: 4 - quarterly
data; 12 - monthly data
• Two stages:
• Obtain MA, centered halfway between t and t-1.
• To get a trend take the average of two successive estimates. Estimate
centered halfway between t and t-1.
31
Moving Averages
• E.g. For k=4
Stage 1.
y y y y
MA .
4
y y y y
MA .
4
Stage 2. MA . MA .
MA
2
and so on.
32
16
8/11/2022
Moving Averages
4-Quarter Centered
• Average periods of 2.5 or 3.5
Average Moving Centered Moving don’t match the original
Period Average Period Average
periods, so we average two
2.5 28.75 3 29.88
consecutive moving
3.5 31.00 4 32.00
4.5 33.00
averages to get centered
5 34.00
5.5 35.00 6 36.25
moving averages
6.5 37.50 7 38.13
7.5 38.75 8 39.00
8.5 39.25 9 40.13
9.5 41.00
33
34
17
8/11/2022
Exponential Smoothing
• This method provides an exponentially weighted moving average of all
previously observed values.
• Appropriate for data with no predictable upward or downward trend, no
seasonality
• The aim is to eliminate random variations and estimate the current level
and use it as a forecast of future value.
35
Exponential Smoothing
• Observed time series: Y1, Y2, …, Yn
• The equation for the model is
𝐒𝐭 𝛂𝐘𝐭 𝟏 𝟏 𝛂 𝐒𝐭 𝟏
36
18
8/11/2022
Exponential Smoothing
• The equation can also be written as
𝐒𝐭 𝐒𝐭 𝟏 𝛂 𝒀𝐭 𝟏 𝑺𝐭 𝟏
𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭 𝐒𝐭 𝛂 𝐘𝐭 𝐒𝐭
37
38
19
8/11/2022
39
SSE 10.945
MSE 2.74
n 1 4
40
20
8/11/2022
41
𝒀 𝜷𝟎 𝜷𝟏 𝒕 𝜺
𝒀 𝒃𝟎 𝒃𝟏 𝒕
21
8/11/2022
∑ 𝑡 𝑡̅ 𝑌 𝑌 ∑ 𝑡𝑌 ∑ 𝑡 ∑ 𝑌 /𝑛
𝑏 𝑏 𝑌 𝑏 𝑡̅
∑ 𝑡 𝑡̅ ∑𝑡 ∑ 𝑡 /𝑛
43
44
22
8/11/2022
45
∑ 𝑡 𝑡̅ 𝑌 𝑌 444
𝑏 7.4
∑ 𝑡 𝑡̅ 60
𝑌 349.67 7.4𝑡
46
23
8/11/2022
47
𝒀 = b0 + b1t + b2t 2
𝒀 = b0 + b1(1/t)
48
24
8/11/2022
49
50
25
8/11/2022
• Additive model:
• Y=T+S+IY–T=S+I
• Multiplicative model:
• Y=TxSxIY/T=SxI
51
2. Average S to remove I
52
26
8/11/2022
53
Year Q1 Q2 Q3 Q4
1 18.4 12.0
2 -37.0 7.8 37.2 -28.0
3 -12.6 18.6 -6.8 10.0
4 -6.2 -21.6
Total -55.8 4.8 48.8 -6.0
Average (S) -18.6 1.6 16.3 -2.0
54
27
8/11/2022
Q1 Q2 Q3 Q4 Total
Unadjusted S -18.60 1.60 16.27 -2.00 -2.73
Adjustment to reduce total
variation to zero 0.68 0.68 0.68 0.68 2.73
Adjustment S -17.92 2.28 16.95 -1.32 0.00
55
56
28
8/11/2022
57
Year Q1 Q2 Q3 Q4
58
29
8/11/2022
Q1 Q2 Q3 Q4 Total
59
60
30
8/11/2022
61
Activity
• The data values in the table below show quarterly sales of a corporation
over a period of six years.
62
31
8/11/2022
Activity
• Task 1: draw a time plot of this series, and discuss its features
• Task 2: compute the four-periods MA to find the trend and apply the
multiplicative model to calculate the seasonal component
• Task 3: compute the linear regression to find the trend and apply the
additive model to calculate the seasonal component
63
What is Forecasting?
• Process of predicting a future event
• Underlying basis of all business decisions
• Production
• Inventory
• Personnel
• Facilities
•…
64
32
8/11/2022
Forecasting Methods
Forecasting
Methods
Quantitative Qualitative
65
Forecasting Methods
• Qualitative Methods: generally involve the use of expert judgment to
develop forecasts.
• Such methods are appropriate when historical data on the variable
being forecast are either not applicable or unavailable.
• E.g. Forecasting on new products, new technology…
66
33
8/11/2022
Forecasting Methods
• Quantitative Methods: can be used when
• Past information about the variable being forecast is available,
• The information can be quantified, and
• It is reasonable to assume the pattern of the past will continue
• In such cases, a forecast can be developed using a time series method or
a causal method.
→ We will focus exclusively on quantitative forecasting methods in this
chapter.
67
68
34
8/11/2022
69
70
35
8/11/2022
71
72
36
8/11/2022
73
Forecast Accuracy
• Measures of forecast accuracy are used to determine how well a particular
forecasting method is able to reproduce the time series data that are
already available.
• Measures of forecast accuracy are important factors in comparing different
forecasting methods.
• By selecting the method that has the best accuracy for the data already
known, we hope to increase the likelihood that we will obtain better
forecasts for future time periods.
74
37
8/11/2022
Forecast Accuracy
• The key concept associated with measuring forecast accuracy is forecast
error.
75
Forecast Accuracy
Mean Error (ME)
• A simple measure of forecast accuracy is the mean or average of the
forecast errors.
∑ Y F
ME
n
• Because positive and negative forecast errors tend to offset one another,
the mean error is likely to be small. Thus, the mean error is not a very
useful measure.
76
38
8/11/2022
Forecast Accuracy
Mean Absolute Error (MAE)
• It is the mean of the absolute values of the forecast errors.
∑ Y F
MAE
n
• This measure avoids the problem of positive and negative errors offsetting
one another.
77
Forecast Accuracy
Mean Squared Error (MSE)
• This is another measure that avoids the problem of positive and negative
errors offsetting one another. It is the average of the squared forecast
errors.
∑ Y F
MSE
n
78
39
8/11/2022
Forecast Accuracy
Mean Absolute Percentage Error (MAPE)
• The size of MAE and MSE depend upon the scale of the data, so it is
difficult to make comparisons for different time intervals. To make such
comparisons we need to work with relative or percentage error measures.
The MAPE is the average of the absolute percentage errors of the
forecasts.
𝑌 𝐹
∑ 𝑥100
𝑌
MAPE
𝑛
79
80
40
8/11/2022
81
82
41
8/11/2022
83
53.3
MAE 7.61
7
489.45
MSE 69.92
7
44.22
MAPE 6.32%
7
84
42
8/11/2022
S αY 1 α S S α Y S
85
86
43
8/11/2022
𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭 𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭
Week Sales
with 𝛂= 0.1 with 𝛂= 0.8
1 110 110.00 110.00
2 115 110.00 110.00
3 125 110.50 114.00
4 120 111.95 122.80
5 125 112.76 120.56
6 120 113.98 124.11
7 130 114.58 120.82
8 115 116.12 128.16
9 110 116.01 117.63
10 130 115.41 111.53
87
88
44
8/11/2022
89
90
45
8/11/2022
91
𝒀 𝒃𝟎 𝒃𝟏 𝒕
• For E.g. of Auger's Plumbing Service, forecast the number of repair jobs
Auger's will perform in December
• December, t=10.
92
46
8/11/2022
94
47
8/11/2022
95
96
48
8/11/2022
97
49
8/11/2022
99
100
50
8/11/2022
Note
• The trend line of the deseasonalized data can be linear or nonlinear
• Choose the best method based on forecast accuracy
101
Using SPSS
• Defining Dates: generates date variables used to establish periodicity and
to distinguish between historical, validation, and forecasting periods
• Data / Define Dates
102
51
8/11/2022
Using SPSS
• Determine the trend line regression
Analyze / Regression / Curve Estimation…
103
SSR
SSE
P-value
for F test
SST = SSR+SSE F = MSR/MSE
104
52
8/11/2022
b0
𝒔𝒃𝟏 P-value
𝒃𝟏 𝒃𝟐 for t test
𝒔𝒃𝟐 𝒕 𝒕
𝒔𝒃𝟏 of b2
𝒔𝒃𝟐
105
Using SPSS
Choose the best line fit
• F or Sig F
• T test of coefficient b1, b2, … or Sig (P-value for t test)
• MSE min, R2 max
106
53
8/11/2022
Using SPSS
• Forecast based on the best line fit
Analyze > Regression > Curve Estimation > Save
Predicts for all cases in the
file
107
108
54
8/11/2022
Summary
• Introduced time series and components of time series
• Described smooth techniques to smooth time series
• Discussed estimating the linear and nonlinear trend line
• Discussed finding seasonal variation
• Introduced forecasting and time series forecasting methods
• Selected the best forecasting method
109
55