Professional Documents
Culture Documents
Production Quantity
185 19,200
1-Oct
1-Oct
1-Nov
1-Dec
1-Jul
1-Nov
1-Dec
1-Jan
1-Jan
1-Apr
1-Jun
1-Aug
1-Sep
1-Aug
1-Sep
1-Mar
1-May
1-Feb
12-Apr 640 49,600
12-May 250 21,300
12-Jun 370 24,500
12-Jul 670 56,200
12-Aug 690 72,100
12-Sep 720 91,300
12-Oct 440 26,000 Cost over time
12-Nov 320 22,800 100,000
40,000
20,000
pence)
50,000
dimensional data points 40,000
30,000
20,000
Differences: 10,000
0
Production Quantity
700
pence)
Similarity: 50,000
40,000
30,000
Mathematical principles 20,000
10,000
0
Differences: 0 200 400 600 800
Production Quantity
We may have additional 700
x
x x x
TSt x
x x x x x
x x
x
t
Non-linear trend
pattern
TSt
Graph of a time series -
Trend component
Trend
Quarterly demand over 6 years
Demand
180
160
140
120
100
80
60
40
20
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Quarter
The Seasonal component
• A seasonal pattern exists when a time series fluctuates
according to some ‘seasonal’ factor
– months of the year
– four seasons of the year
– days of the week
– hours of the day
– ....
• Examples:
– Shopping behaviour
– Electricity usage
– …
Seasonal Data Pattern
TSt
e.g. 1 year
t
Graph of a time series -
Seasonal component
Quarterly demand over 6 years
Demand
180 seasonal
160
140
120
100
80
60
40
20 Year 1 Year 2 Year 3 Year 4 Year 5 Year 6
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Quarter
The Cyclical component
Examples:
- House prices
- Sales of i-phones
Cyclical data pattern
TSt
> 1 year
t
Graph of a time series -
cyclical component
Quarterly demand over 6 years
Dem and cyclical
200
150
100
50
Year 1 Year 2 Year 3 Year 4 Year 5 Year 6
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Quarter
(Downturn) in Year 5
Graph of a time series -
irregular component
Quarterly demand over 6 years
Dem and
200
150
100
50
Year 1 Year 2 Year 3 Year 4 Year 5 Year 6
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Quarter
100
50
0
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
33 120
120 160
44 110
110
22 15 98
98 140
26 92
92 120
37 140
140
48 120 100
Demand
120
33 19 100
100 80
10 2 95
95
3 135 60
11 135
12 4 120
120 40 y = 2.425x + 94.075
44 13 1 110
110 R² = 0.3394
20
14 2 120
120
15 3 160
160 0
4 130 0 2 4 6 8 10 12 14 16 18
16 130
Quarter
Identifying trend
Alternatively, can use a Moving Average
- Will de-seasonalise the data
Actual MA(4) Centred - Requires appropriate choice of the number of
95 the periods in the Moving Average
90
103.75
120 104.13
104.50
110 105.00 104.75 Actuals versus 4 period Moving average
98 110.00 107.50 180
92 112.50 111.25 160
140 113.00 112.75 140
120 113.75 113.38 120
100 112.50 113.13 100
95 113.75 113.13 80
135 116.25 Actual
115.00 60
125 119.50 117.88 40 MA(4)
110 125.75 122.63 20
108 127.00 126.38 0
160 128.50 127.75 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
130 126.00 127.25
116 121.25 quarter
123.63
98 121.75 121.50
141 123.67 Note we use centred values when we have an
132
even number of periods in the moving average
Try this – Moving Averages
• Calculate an MA(3) and MA(7) for the
following sales data from a shoe shop in
the Trafford Centre
Date Sales (in Pairs of Shoes)
9.3.2013 132
10.3.2013 110
Which of the two
11.3.2013 45
moving averages
12.3.2013 35
would you expect to
13.3.2013 23
be more appropriate
14.3.2013 36
(and why)?
15.3.2013 54
16.3.2013 145
17.3.2013 121
Calculation of MA(3) and
MA(7)
Date Sales (in Pairs MA(3) MA(7)
of Shoes)
9.3.2013 132
10.3.2013 110 96
11.3.2013 45 63
12.3.2013 35 34 62
13.3.2013 23 31 64
14.3.2013 36 38 66
15.3.2013 54 78
16.3.2013 145 107
17.3.2013 121
Visual comparison
160
140
Sales (in Pairs of Shoes)
120
100
80
Original data
60 MA(3)
40
MA(7)
20
0
Classical Decomposition
Analysis
• Trend (T)…… Least Squares Regression (LSR)
Moving Averages (MA)
• Seasonal (S)… value (additive model)
Index (multiplicative model)
(e.g. ratio of actual to trend or MA)
9.3.2013
10.3.2013
11.3.2013
Tuesday
35/62=0.56
Wednesday
23/64=0.36
Thursday
36/66=0.55
15.3.2013
16.3.2013
17.3.2013
A look towards - Forecasting
?
Forecasts for the example
Qtr Actual Trend S. Index Forecast
1 95 96.50 0.90 87
2 90 98.93 0.88 87 These forecasts
3 120 101.35 1.21 122
were obtained by
4 110 103.78 1.02 106
5 98 106.20 0.90 95
using a
6 92 108.63 0.88 95 multiplicative
7 140 111.05 1.21 134 model of the
8 120 113.48 1.02 115 form:
9 100 115.90 0.90 104
10 95 118.33 0.88 104
11 135 120.75 1.21 146 Ft = Tt*St
12 120 123.18 1.02 125
13 110 125.60 0.90 113 and then
14 120 128.03 0.88 112 rounding the
15 160 130.45 1.21 157 result.
16 130 125.55 1.02 128
Graph of actual versus forecasts
Demand
Actual versus forecasts
Actual
180
Forecast
160
140
120
100
80
Notice how good the forecasts are in this
60
case.
40
This is because we are only forecasting the
20
period over which we built the model.
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Quarter
Summary: Classical
decomposition
The analysis stage identifies the basic features of a time series i.e.
trend (T), seasonals (S), cyclicals (C) and irregulars (I).
?
Qtr Actual Trend S. Index Forecast
1 95 96.50 0.90 87
2 90 98.93 0.88 87
3 120 101.35 1.21 122
Try this: 4 110 103.78 1.02 106
5 98 106.20 0.90 95
6 92 108.63 0.88 95
7 140 111.05 1.21 134
Model for trend:
8 120 113.48 1.02 115
y = 2.425x + 94.075 9 100 115.90 0.90 104
10 95 118.33 0.88 104
Model for seasonal 11 135 120.75 1.21 146
variation (seasonal 12 120 123.18 1.02 125
index):
13 110 125.60 0.90 113
14 120 128.03 0.88 112
Q1 0.90 15 160 130.45 1.21 157
Q2 0.88 16 130 125.55 1.02 128
Q3 1.21 17 NA 135.30 0.90 121.77
Q4 1.02 18 NA 137.73 0.88 121.20
19 NA 140.15 1.21 169.58
Ft = Tt*St 20 NA 142.58 1.02 145.43
Outline
Worked example
• The “art” of forecasting
• Steps of time series analysis and
forecasting
Quarter Sales (in 100s)
A worked Q1 2008 6.51
Q2 2008 23.08
example Q3 2008
Q4 2008
39.88
53.27
Q1 2009 69.82
A firm has recorded the
Q2 2009 147.53
sales for a particular product
Q3 2009 180.36
at the end of each quarter
Q4 2009 189.43
over the last 4 years as
Q1 1010 213.48
follows:
Q2 2010 388.61
Q3 2010 434.37
Q4 2010 410.20
Q1 2011 426.12
Q2 2011 741.31
Q3 2011 756.37
Q4 2011 718.62
Q1 2012 727.46
Graph of time series
Cyclicals?
Sales over the past four years Trend?
900.00
800.00
700.00 Seasonal
600.00 Variation?
Sales (in £)
500.00
400.00
300.00
200.00
100.00
0.00
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1
2008 2008 2008 2008 2009 2009 2009 2009 1010 2010 2010 2010 2011 2011 2011 2011 2012
Seasonal component TS MA(3)
6.51
23.08 23.16
• First step requires 39.88 38.74
53.27 54.32
calculation of a moving 69.82 90.21
average for an appropriate 147.53 132.57
number of periods 180.36 172.44
189.43 194.43
213.48 263.84
388.61 345.49
• Centred moving average is 434.37 411.06
then plotted as a function of 410.20 423.56
426.12 525.88
the centre of the window 741.31 641.27
756.37 738.77
718.62 734.15
727.46
Seasonal TS MA(4) Adjusted MA(4)
1.03
2008 2009 2010 2011 Mean Adjusted
0.86
0.73 Q1 0.73 0.78 0.78 0.76 0.79
1.14
1.09 Q2 1.14 1.16 1.19 1.16 1.20
0.89
0.78 Q3 1.03 1.09 1.12 1.08 1.08 1.11
1.16
1.12 Q4 0.86 0.89 0.89 0.88 0.91
0.89 3.89 4.00
0.78
1.19
1.08 Adjusted Index is obtained as Mean*Expected Sum/Sum
Use of the seasonal index
to de-seasonalize the data
Seasonal
Quarter TS Index Deseasonalized TS
Q1 2008 6.51 0.79 8.28
Q2 2008 23.08 1.20 19.28
Deseasonalized data is Q3 2008 39.88 1.11 35.88
obtained by dividing Q4 2008 53.27 0.91 58.82
the original time series Q1 2009 69.82 0.79 88.87
data by the seasonal Q2 2009 147.53 1.20 123.23
index Q3 2009 180.36 1.11 162.27
Q4 2009 189.43 0.91 209.16
Q1 1010 213.48 0.79 271.75
Q2 2010 388.61 1.20 324.58
Q3 2010 434.37 1.11 390.80
Q4 2010 410.20 0.91 452.92
Q1 2011 426.12 0.79 542.42
Q2 2011 741.31 1.20 619.18
Q3 2011 756.37 1.11 680.50
Q4 2011 718.62 0.91 793.48
Q1 2012 727.46 0.79 922.03
Original graph of time series
900.00
800.00
700.00
600.00
Sales (in £)
500.00
400.00
300.00
200.00
100.00
0.00
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1
2008 2008 2008 2008 2009 2009 2009 2009 1010 2010 2010 2010 2011 2011 2011 2011 2012
Visualization of de-
seasonalized data Form of trend?
1000.00
900.00
800.00
Sales (in 100s)
700.00
600.00
500.00
400.00
300.00
200.00
100.00
0.00
0 2 4 6 8 10 12 14 16 18
Quarter
1000.00
How can we
900.00
data
800.00
Sales (in 100s)
700.00
600.00
500.00
400.00
300.00
200.00
100.00
0.00
0 2 4 6 8 10 12 14 16 18
Quarter
Note the move from categorical labels (Quarters) to a
numerical ordering (x-axis) to perform the linear
regression and evaluate the resulting model.
Linear trend?
1000.00
y = 55.82x - 166.89
R² = 0.9471
800.00
Sales (in 100s)
600.00
400.00
200.00
0.00
0 2 4 6 8 10 12 14 16 18
-200.00
Quarter
Polynomial trend?
1000.00
y = 2.9997x2 + 1.8254x + 4.0981
900.00
R² = 0.999
800.00
Sales (in 100s)
700.00
600.00
500.00
400.00
300.00
200.00
100.00
0.00
0 2 4 6 8 10 12 14 16 18
Quarter
Forecasting
Seasonal
TS Index Trend Forecast
6.51 0.79 8.92 7.01
23.08 1.20 19.75 23.64
39.88 1.11 36.57 40.65
53.27 0.91 59.39 53.79
In a multiplicative model, the 69.82 0.79 88.22 69.30
forecast is obtained as 147.53 1.20 123.04 147.31
180.36 1.11 163.86 182.13
Forecast=Trend*Seasonal Index 189.43 0.91 210.68 190.81
(assuming no cyclical component 213.48 0.79 263.50 207.01
and ignoring the irregular 388.61 1.20 322.32 385.90
component), 434.37 1.11 387.14 430.30
410.20 0.91 457.96 414.76
426.12 0.79 534.78 420.12
741.31 1.20 617.59 739.42
756.37 1.11 706.41 785.17
718.62 0.91 801.23 725.64
727.46 0.79 902.04 711.69
Graphical comparison
Comparison Extrapolation
2000.00
1800.00
1600.00
1400.00
1200.00
Sales (in 100s)
1000.00
Forecast
800.00
TS
600.00
400.00
200.00
0.00
0.00 5.00 10.00 15.00 20.00 25.00 30.00
Quarters
Forecast Error
Compare forecasts with actuals:
- Graphically
- Quantitative measures of forecast error, e.g. based on the mean or
average of the differences between actuals and forecasts
– MAE (Mean Absolute Error)
– MSE (Mean Square Error)
MAE and MSE are known as ‘absolute’ measures and can be used to
compare different forecasts of the same time series (e.g. to select the
best forecasting model).
Forecasts
Knowledge and
Experience EXTRAPOLATION predictions
Insight to plan
ahead
Causal:
Price Demand
Past and
present Future
Time series: demand demand
over time over time
Practical Relevance of Forecasting
Forecasting is both ‘art’
and ‘science’
Forecasts
Long & short term
forecasting
Distinction between
• long-term and
• short-term forecasting
Key difference: The number of periods that are
forecast ahead from the present time.
In general: The further ahead the less likely
(accurate) the forecasts will be.
Application: For operational planning we are
usually interested in short-term forecasting
whilst for strategic planning we are interested
in long-term forecasting.
Time Series forecasting
1 2 3 4 5 6 7 8 9
Split data
Analyse data
Select/construct models
Outliers
Level Shift
Special Events
• Such as Promotions, strikes etc as well
as Earthquakes etc
If this series stands for
monthly Check Ups in NHS
centres …