Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

Unit 3: Time Series Forecasting

Management Science

MICHAEL BONN A. BONIFACIO, MSPPM


Alumnus
Carnegie Mellon University
Demand Forecasting

 Example: We would like to forecast the number of sales in future months,


given historical sales figures. This has obvious implications for production and
logistics
Time Period Number of VCRs Sold
1 33
2 38
3 31
4 35
5 30
6 36
7 34
8 39
9 39
10 36
11 40
12 38
13 37
14 39
15 32
16 38
17 37
18 39
19 37
20 35
21 37
22 34
23 35
24 36

2
Ingredients of Forecasting

 In a forecasting problem
 You have historical data
 You choose a model that fits a pattern onto the data
 The model help you forecasts for future values based on these
patterns

 For example a three month period values:

 That is, your prediction is the average of the past 3


measurements
3
A Simple Model: 3-Months Moving Average Forecast

 The three-months average forecasting can be


drawn as shown
 Note that for last three months where no data is
available, we use forecasted values
Time Period Number of VCRs Sold
1 33
2 38
3 31 Three Months Average
4 35 34.00
5 30 34.67
6 36 32.00
7 34 33.67
8 39 33.33
9 39 36.33
10 36 37.33
11 40 38.00
12 38 38.33
13 37 38.00
14 39 38.33
15 32 38.00
16 38 36.00
17 37 36.33
18
19
39
37
35.67
38.00
Excel formulas:
20
21
35
37
37.67
37.00
 C6 = AVERAGE(B3:B5) (Copy to
22 34 36.33 C7:C27)
23 35 35.33
24 36 35.33  C28 = AVERAGE(B25:B26, C27)
25 35.00
26 35.33  C29 = AVERAGE(B26, C27:C28)
27 35.44
28 35.26  C30 = AVERAGE(C27:C29)
4
Discussion

 How could a 3 period moving average possibly predict the future?

 Unfair to expect clairvoyance. More reasonable question: is it better than


following your gut instinct?
 For example, gut instinct might put too much importance on the most
recent measurement
 Gut instinct might be put too much importance on an especially good or
bad day in the past
 In the behavioral sciences, predictions are very often wrong
 Unlike physics where we can predict very accurately
 For example, path of a projectile, results of chemical reactions, visit of
Haley's comet, etc.
 There will be times when this (or any) rule will fail to give good
predictions.
 Predictions should therefore only be taken as educated guesses.

5
Weighted Moving Averages

 Example of a parameterized forecasting model: weighted moving


averages.
 Example: period 3 moving average model:

where w1, w2, and w3 ≥ 0 and w1 + w2 + w3 = 1.

6
Choosing the Parameter Values

 The weights w1, w2, and w3 are examples of parameters which customize a
model behavior. How should we choose them?

 One method for choosing a parameter is to pick the values that gives the best
predictions on the data so far
 Intuition: in hindsight, this would have given the best predictions
 (Of course, hindsight is not guaranteed to predict future performance)

 How should we measure which gives the “best” predictions?


 Common choice: mean square error (MSE)

 Note: we will use MSE interchangeably with sum of square errors (SSE)
7
A Simple Model: 3-Months Weighted Moving Average Forecast

 A weighted three-months average while minimising


mean-square error using Solver is as shown
 Note that again for last three months where no data
is available, we use forecasted values
Time Period Number of VCRs Sold
1 33
2 38
3 31 Forecast
4 35 35.59
5 30 32.72
6 36 33.24 Parameters
7 34 32.12
W1 0.08
8 39 34.93
9 39 35.59
W2 0.63
10 36 38.59 W3 0.29
11 40 38.14 SUM 1.00
12 38 37.39
13 37 39.10 Perforamnce Measure
14 39 37.88 MSE 5.92
15 32 37.65
16 38 36.84
17 37 34.29 Excel formulas:
18 39 37.22
19 37 37.65  F9 = SUMXMY2(B6:B26,C6:C26)/COUNT(B6:B26)
20 35 38.26
21 37 36.59  C6 = SUMPRODUCT(B3:B5, F$3:F$5) (Copy to
22 34 35.74
23 35 35.98 C7:C27)
24 36 34.53
25 35.20  C28 = B25*F3+B26*F4+C27*F5
26 35.69
27 35.41
 C29 = B26*F3+C27*F4+C28*F5
28 35.57
 C30 = SUMPRODUCT(C27:C29, F3:F5)
8
Notes on Solver Optimization

 In this section we used the GRG non-linear Solver


 Since our equations were nonlinear

 The GRG solver:


 Searches in the vicinity of the current solution for a better one.
 Stops when the search fails to find a better solution. This is called a
“local optimum”

 As a result, it is not guaranteed to find the optimal (or “globally


optimal”) solution to an optimization problem

 Also, it can give different answers from one try to the next

9
Recursive Forecasting

 In some models, the formulas are recursive


 That is, your next prediction is a function of the previous prediction
 Obviously we need to start by initializing the model somehow

 Example: exponential smoothing


 Split the difference between your previous estimate and the previous data
point

 Current estimate is function of previous estimate


 Initialize
 is a parameter bounded between 0 and 1
 Choose by minimizing mean square error (MSE), like in the weighted
monthly average forecasting

10
Exponential Smoothing Model

 The a parameter is minimised through MSE,


works similar to a moving average, but data
is never “thrown away” completely
 This forecasting method is only good for one
period.
Time Period Number of VCRs Sold Forecast
1 33 33.00
2 38 33.00
3 31 34.34
4 35 33.44
5 30 33.86
6 36 32.83
7 34 33.68
8 39 33.76 Parameters
9 39 35.17
10 36 36.19
alpha 0.268
11 40 36.14
12 38 37.18 Perforamnce Measure
13 37 37.40
MSE 7.82
14 39 37.29
15 32 37.75
16 38 36.21
17 37 36.69
18 39 36.77
19
20
37
35
37.37
37.27
Excel formulas:
21
22
37
34
36.66
36.75
 C3 = B3 (Initializing)
23
24
35
36
36.02
35.74
 C4 = (1-F$3)*C3+F$3*B3 (Copy to
25 35.81 C4:C27)
26 35.81
27 35.81  C28 = (1-F$3)*C28+F$3*C28 (Copy to
28 35.81
C4:C27) 11
Varying a Manually

 Let’s look at the formula again:

 For small values of a, estimates change very slowly. Here, a = 0.01 is too
small, as your prediction is basically the first observation. However, a = 0.01
can be okay for larger data sets.
 For large values of a, changes rapidly, and your prediction is basically the
most recent observation

 a = 0.01  a = 0.30  a = 0.90

12
Seasonal Effects

 There exists many examples of seasonal data


 For example: air conditioners in summer, house sales during the fall, etc.
 Data can be periodic in other time scales as well
 For example : automobile traffic cycles throughout the day, days of the week, and month
 In these cases, your most recent data is less predictive than data from “one full cycle ago”
Year Qtr Time Period Units Sold
2005 1 1 330
2 2 310
3 3 370
4 4 300
2006 1 5 378
2 6 352
3 7 408
4 8 341
2007 1 9 354
2 10 329
3 11 402
4 12 303
2008 1 13 358
2 14 317
3 15 402
4 16 299
2009 1 17 340
2 18 303
3 19 387
4 20 305
2010 1 21 360
2 22 346
3 23 396
4 24 324
13
Additive and Multiplicative Seasonal Effects

 Seasonal effects can


be additive, which
result in a similar
amount added during
each period, or
multiplicative where
the amount increase
by a growth factor
every year, but also
maintains seasonality
where the amount
goes up and down
according to season.

14
Additive Seasonal Effects

 Assume data is a sum of a stationary term


E and a seasonal term S (which repeats
every p periods):

 Exponential smoothing on E and S


separately would give the side formulas
using a and b
 However we don’t know either E or S

 As we cannot measure either Et or St ,


therefore we substitute expressions which
involve Yt and estimate them:

 Finally, we combine past estimates of E


and S to predict Y: 15
Exponential Smoothing and Seasonality Forecasting

 Note we are finding two parameters of a and b


which minimise the MSE for the stationary and
periodic parts of the data series
Year Qtr Time Period Units Sold Level Seasonality Forecast
2005 1 1 330 327.50 2.50 -
2 2 310 327.50 -17.50 -
3 3 370 327.50 42.50 -
4 4 300 327.50 -27.50 -
2006 1 5 378 355.21 8.12 330.00
2 6 352 363.46 -15.83 337.71
3 7 408 364.64 42.74 405.96
4 8 341 366.87 -27.05 337.14
2007 1 9 354 354.75 5.66 374.99
2 10 329 349.02 -16.99 338.93
3 11 402 354.93 43.94 391.76
4 12 303 340.57 -29.96 327.89
2008 1 13 358 347.36 7.04 346.23
2 14 317 339.64 -18.55 330.37
3 15 402 350.28 46.09 383.58
4 16 299 337.97 -32.46 320.32
2009 1 17 340 335.08 6.45 345.01
2 18 303 327.27 -20.14 316.52 Excel formulas:
3 19 387 335.14 47.69 373.36  E5 = AVERAGE($D$5:$D$8) Copy to E6:E8
4 20 305 336.48 -32.18 302.69
 F5 = D5 – E5 Copy to F6:F8
2010 1 21 360 346.33 8.45 342.93
2 22 346 357.77 -17.82 326.19  E9 = (1-$I$7)*E8 + $I$7*(D9-F5) Copy to
3 23 396 352.31 46.58 405.45 E10:E28
4 24 324 354.55 -31.73 320.12
2011 1 25 363.00  F9 = (1-$I$8)*F5 + $I$8*(D9-E9) Copy to
2 26 alpha 0.5773 336.73 F10:F28
3 27 beta 0.2769 401.13  G9 = E8 + F5 Copy to
4 28 322.81
G10:G28 16
MSE 304.43
Exponential Smoothing and Seasonality Forecasting

17
Alternative: Multiplicative Seasonal and Trend

 Multiplicative may better reflect reality


as the average level increases, the
seasonal swings increase proportionally
 Similar to the previous example one can
assume that the data series contains a
trend and seasonal effects
 Ideally, we’d use exponential smoothing
on E, T, and S. However, this is not
possible since we do not know these
parameters.

 As we cannot observe E, T, and S, we


substitute previous estimates instead
using the same exponential mechanism
as before:

 This is same as before except that the


seasonal effect is multiplicative

18
Smoothing and Multiplicative Seasonality and Trend Forecasting

Year Qtr Time Period Actual Sales Base Level Trend Seasonal Forecast
2001 1 1 $ 684.20 731.5 0.0 0.935
2 2 $ 584.10 731.5 0.0 0.799
3 3 $ 765.38 731.5 0.0 1.046
4 4 $ 892.28 731.5 0.0 1.220
2002 1 5 $ 885.40 783.8 52.3 1.087 $ 684.20
2 6 $ 677.02 838.9 55.1 0.805 $ 667.56
3 7 $ 1,006.63 910.6 71.7 1.092 $ 935.45
4 8 $ 1,122.06 967.1 56.5 1.173 $ 1,198.12
2003 1 9 $ 1,163.39 1035.0 67.9 1.116 $ 1,112.49
2 10 $ 993.20 1134.6 99.6 0.860 $ 887.98
3 11 $ 1,312.46 1226.3 91.7 1.075 $ 1,348.37
4 12 $ 1,545.31 1317.7 91.4 1.173 $ 1,546.44
2004 1 13 $ 1,596.20 1414.3 96.6 1.126 $ 1,572.40
2 14 $ 1,260.41 1499.9 85.6 0.845 $ 1,299.21
3 15 $ 1,735.16 1592.4 92.5 1.086 $ 1,704.79
4 16 $ 2,029.66 1696.0 103.6 1.191 $ 1,976.25
2005 1 17 $ 2,107.79 1817.2 121.2 1.152 $ 2,025.99
2 18 $ 1,650.30 1942.2 125.0 0.849 $ 1,637.27 Excel formulas:
3 19 $ 2,304.40 2080.3 138.1 1.103 $ 2,245.85  E4:E7 = average(D4:D7)
4 20 $ 2,639.42 2217.6 137.3 1.190 $ 2,643.07
 F4:F7 = 0
2006 1 21 $ 2,713.73
2 22 $ 2,114.86  G4 = D4 / E4 Copy to
3 23 $ 2,900.50 G5:G7
4 24 Parameters $ 3,293.93
alpha 0.24
 E8 = (1-$J$7)*(E7+F7) +$J$7*(D8/G4) Copy to
beta 1.00 E9:E23
gamma 0.78  F8 = (1-$J$8)*F7+$J$8*(E8-E7) Copy to
F9:F23
Perforamnce Measure
MSE 5157.69  G8 = (1-$J$9)*G4+$J$9*(D8/E8) Copy to
G9:G23
 H8 = (E7+F7)*G4 Copy to 19
Which Method Should We Choose?

 There are three main types of forecasting models


(and combinations thereof):
1. Stationary forecasting: finds the average while
discounting old data
 Example: exponential smoothing

2. Periodic/Seasonal forecasting: history repeats


itself
 Example: seasonal additive

3. Trend forecasting: extrapolating beyond the past


 Example: holt-winters

 Very important to make right choice. May depend


on circumstances (i.e., do you want to extrapolate
a trend? are the sales seasonal?) 20
Difficult to Improve

 More complicated formulas tend not to improve results


 Better to use side information
 Ex: Aztech Industries sells oil and lubricants
 Forecast future sales not only from past sales, but also from
regional rainfall and weather data
 One method for such cases: Kalman Filtering
 Beyond scope of this course

 We skipped over
 Slight variations on lecture material
 Trend model, without any seasonal effects
 Multiplicative seasonal effects, without any trends

21

You might also like