Exponential Smoothing Lecture Notes

advertisement
BABS 502
Moving Averages, Decomposition
and Exponential Smoothing
Revised March 11, 2014
500
450
400
350
300
250
200
150
100
50
1992
1990
1988
1986
1984
1982
1980
1978
1976
1974
1972
1970
0
1
Single Exponential Smoothing
 One-step ahead forecast is the weighted average of
current value and past forecast
 Ft(1) = a(Current Value)+ (1-a) Past Forecast
aXt+ (1-a) Ft-1(1)
 Alternative representation
Ft(1) = Ft-1(1) + a [ Xt - Ft-1(1) ]
=
• This is previous forecast plus a constant times previous forecast
error
 Text also gives a component form representation
 To apply this we need to choose the smoothing weight a
 The closer a is to 1, the more reactive the forecast is
to changes
© Martin L. Puterman – Sauder School of Business
2
Single Exponential Smoothing
Recursive function:
 Ft(1) = aXt+ (1-a) Ft-1(1),
 Ft-1(1) = aXt-1+ (1-a) Ft-2(1), etc
Backward substitute:
 Ft(1) = aXt + (1-a)aXt-1 + (1-a)2 aXt-2 + (1-a)3 aXt-3 +…
When a = 0.3 this becomes
 Ft(1) = .3Xt+ .7*.3 Xt-1 + (.7)2 *.3Xt-2 + (.7)3 .3Xt-3 + …
= .3Xt+ .21 Xt-1 + .147 Xt-2 + .1029 Xt-3 + …
This is the justification for the name “exponential”
smoothing. “Age” of data is about 1/a which is
the mean of the geometric distribution.
© Martin L. Puterman – Sauder School of Business
3
Single Exponential Smoothing
Example
Diagram 3.2: SES results with different smoothing parameters
280
260
Sales
240
220
200
180
Sales
Alpha = 0.1
160
Alpha = 0.7
140
1
4
7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76
Tim e
© Martin L. Puterman – Sauder School of Business
4
Single Exponential Smoothing
Component Form
Today’s level = a * Today’s value +
(1-a)*Yesterday’s Level
Tomorrow’s forecast = Today’s level
Lt = a Xt + (1- a) Lt-1
Ft(k) = Lt for all k
The level represents the systematic part of the
series
© Martin L. Puterman – Sauder School of Business
5
Simple Exponential Smoothing
Spreadsheet Example
Easy to use excel optimizer to choose alpha to minimize
mean absolute percentage out of sample forecast error.
© Martin L. Puterman – Sauder School of Business
6
Single Exponential Smoothing
NCSS Output
Variable
Number of Rows
Mean
Pseudo R-Squared
Mean Square Error
Mean |Error|
Mean |Percent Error|
Pulp_Price
84
579.2857
0.798127
4232.143
44.28571
7.838659
Alpha Search Mean |Percent Error|
Alpha
1
Forecast
540
Pulp_Price Forecast Plot
1000.0
Pulp_Price
800.0
600.0
400.0
200.0
0.9
23.9
46.9
69.9
92.9
Time
© Martin L. Puterman – Sauder School of Business
7
Some Comments on Exponential
Smoothing (Gardner, 1985)
 Starting Values - need F0(1) to start process.
Possible Choices
 Data Mean
 Backcasting
 Simple exponential smoothing is identical to
ARIMA(0,1,1) model.
 Parameter is chosen to minimize either the root
mean square, mean absolute or mean absolute
percentage one step ahead forecast error.
 R chooses to maximize liklehood.
© Martin L. Puterman – Sauder School of Business
8
Some Comments on Out of Sample
Testing
 When comparing methods out of sample
be sure to check how the out of sample
forecast is computed and what
information is assumed known.
 In some automatic programs –
exponential smoothing is applied one step
ahead out of sample so that it uses more
data than other methods.
© Martin L. Puterman – Sauder School of Business
9
Double Exponential Smoothing
In a trending series, single exponential
smoothing lags behind the series
BIRTHS Forecast Plot
400000.0
380000.0
B
I R
T
H S
420000.0
360000.0
340000.0
0.9
11.6
22.4
33.1
43.9
Time
© Martin L. Puterman – Sauder School of Business
10
Double Exponential Smoothing
Double Exponential Smoothing tracks
trending data better; but forecasts may
not be good after a few periods
BIRTHS Forecast Plot
390000.0
360000.0
B
I R T
H S
420000.0
330000.0
300000.0
0.9
9.6
18.4
27.1
35.9
Time
© Martin L. Puterman – Sauder School of Business
11
Double Exponential Smoothing
 Linear Trend Model Yt=0+1t is inflexible. Assumes a
constant trend 1 per period throughout the data.
 Basic idea - introduce a trend estimate that changes
over time.
 Similar to single exponential smoothing but two
equations.
 Issue is to choose two smoothing rates, a and .
 Referred to as Holt’s Linear Trend
 Trend dominates after a few periods in forecasts so
forecasts are only good for a short term.
© Martin L. Puterman – Sauder School of Business
12
Double Exponential Smoothing
 The model: Separate smoothing equations for level and
trend
 Level Equation
Lt = a(Current Value)
+ (1 - a) (Level + Trend Adjustment)t-1
Lt = aXt + (1 - a) (Lt-1 + T
t-1)
 Trend Equation
Tt = (Lt - Lt-1) + (1 - ) Tt-1
 Forecasting Equation
Ft(k) = Lt + k Tt
© Martin L. Puterman – Sauder School of Business
13
Double Exponential Smoothing Example
Double Exponential Smoothing
6.4
W 6.0
a
g
e 5.6
s
5.2
4.8
1
a = 0.637
25
=0.020
F72(1) = 5.916 + 0.013 = 5.929
49
73
L72 = 5.916
Time 97
T72 = 0.013
F72(2) = 5.916 + 0.013*2 = 5.942
© Martin L. Puterman – Sauder School of Business
14
Damped Trend Models
 Problem with a trend model is that trend dominates
forecast in a couple of periods.
 Approach - introduce trend damping parameter 
 Level Equation
Lt = aXt + (1 - a) (Lt-1 + T
t-1)
 Trend Equation
Tt = (Lt - Lt-1) + (1 - ) Tt-1
 Forecasting Equation
k
Ft (k ) = Lt    iTt
 Implemented in R.
i =1
© Martin L. Puterman – Sauder School of Business
15
Seasonality
 A persistent pattern that occurs at regularly
spaced time intervals
 quarterly, monthly, weekly, daily
 Data may exhibit several levels of seasonality
simultaneously
 May be modeled as multiplicative or additive
 Should be included in systematic part of
forecasting model
 Detected visually or through ACF
© Martin L. Puterman – Sauder School of Business
16
Seasonal Data Example
40
79
118
157
0.500
0.000
-0.500
Autocorrelations
1
-1.000
210.0
175.0
140.0
Power
245.0
1.000
Autocorrelations of Power (0,0,12,1,0)
280.0
Plot of Power
0
10
Time
21
31
41
Time
Monthly US Electric Power
Consumption
© Martin L. Puterman – Sauder School of Business
17
Exponential Smoothing with Trend and
Seasonality
Exponential Smoothing with trend does not
track or forecast seasonal data well
sales Forecast Plot
900.0
s a le s
725.0
550.0
375.0
200.0
0.9
7.9
14.9
21.9
28.9
Time
© Martin L. Puterman – Sauder School of Business
18
Exponential Smoothing with Trend
and Seasonality
The Holt-Winters Model tracks the seasonal
pattern
sales Forecast Plot
1000.0
s a le s
800.0
600.0
400.0
200.0
1994.9
1996.6
1998.4
2000.1
2001.9
Time
© Martin L. Puterman – Sauder School of Business
19
Holt-Winters’ Exponential
Smoothing Equations
Level Equation:
 Lt = a(Current Value/Seasonal Adjustmentt-p)
+ (1-a)(Levelt-1 + Trendt-1)
 Lt = a(Deseasonalized Current Value)
+ (1-a)(Levelt-1 + Trendt-1)
 Lt = a(Xt/It-p) + (1-a)(Lt-1 + Tt-1)
where It-p = Seasonal component
© Martin L. Puterman – Sauder School of Business
20
Holt-Winters’ Exponential
Smoothing
 Generalizes Double Exponential Smoothing by including
(multiplicative) seasonal indicators.
 Separate smoothing equations for level, trend and
seasonal indicators.
 Allows trend and seasonal pattern to change over time
 Must estimate three smoothing parameters
 Equations more complicated but implemented with
software
 One of the best methods for short term seasonal
forecasts
© Martin L. Puterman – Sauder School of Business
21
Holt-Winters’ Exponential
Smoothing Equations
Trend Equation:
 Same as double exponential smoothing method
 Tt = (Change in level in the last period)
+ (1 - ) (Trend Adjustment)t-1
 Tt = (Lt - Lt-1) + (1 - ) Tt-1
© Martin L. Puterman – Sauder School of Business
22
Holt-Winters’ Exponential
Smoothing Equations
Seasonal Equation:
 It = g(Current Value/Current Level)
+ (1-g)(Seasonal Adjustment)t-p
 It = g(Xt/Lt) + (1-g)It-p
where p is the length of the seasonality (i.e. p months)
so that t-p is the same season in the previous year.
Note this model assumes the same g for every season.
Forecasting equations:
 Ft(k) = (Lt + kTt)It-p+k
 Ft(k) = (Lt + kTt)It-2p+k
for k=1,2, …, p
for k=p+1,p+2, …, 2p
© Martin L. Puterman – Sauder School of Business
23
Holt-Winters’ Exponential
Smoothing Equations Summary
 Lt = a(Xt/It-p) + (1-a)(Lt-1 + Tt-1) Level Equation
 Tt = (Lt - Lt-1) + (1-)Tt-1
Trend Equation
 It = g(Xt/Lt) + (1- g)It-p
Seasonal Factor Equation
Forecasting equations:
 Ft(k) = (Lt + kTt)It-p+k
 Ft(k) = (Lt + kTt)It-2p+k
for k=1,2, …, p
for k=p+1,p+2, …, 2p
© Martin L. Puterman – Sauder School of Business
24
Holt-Winters’ Exponential
Smoothing Example
Pulp_Price Forecast Plot
1200.0
950.0
Pulp_Price
Forecast Summary Section
Variable
Pulp_Price
Number of Rows
84
Mean
579.2857
Pseudo R-Squared
0.766036
Mean Square Error 4904.916
Mean |Error|
44.74108
Mean |Percent Error| 7.992905
700.0
450.0
200.0
2000.9
2007.1
2013.4
2019.6
2025.9
Time
Forecast Method
Winter's with
multiplicative seasonal adjustment.
Search Iterations
120
Search Criterion
Mean |Percent Error|
Alpha
0.999787
Beta
0.1984507
Gamma
0.4674903
Initial values for forecasts
Intercept (A)
Slope (B)
Season 1 Factor
Season 2 Factor
Season 3 Factor
Season 4 Factor
-113.6628
7.878917
1.008922
0.9970459
0.9850978
1.008935
© Martin L. Puterman – Sauder School of Business
25
Holt-Winters Further Comments
 Can add damped trend to this model too.
 Additive version also available but multiplicative model is
preferable. Note the HW model combines additive trend
with multiplicative seasonality.
 Missing values cannot be skipped, they must be
estimated.
 Outliers have a big impact and could be handled like
missing values
 This is a special case of a “state space model”.
 Different computer packages give different estimates
and forecasts.
 Early reference: Chatfield and Yar “Holt-Winters
forecasting: some practical issues”, The Statistician,
1988, 129-140.
© Martin L. Puterman – Sauder School of Business
26
Applying Exponential Smoothing
Models
 Plot data
 determine patterns
- seasonality, trend, outliers
 Fit model
 Check residuals
 Any information present?
- Plots or ACF functions
 Adjust
 Produce forecasts
 Calibrate on hold out sample
 Multiple one step ahead
 k-step ahead (where is k is the practical forecast horizon)
© Martin L. Puterman – Sauder School of Business
27
Using Exponential Smoothing in Practice
 Important issue is how frequently to recalibrate
the model
 Possible choices
- Every period
- Quarterly
- Annually
 The point here is that the model can be
determined by analysts, programmed into a
forecasting system with fixed parameters and
recalibrated as needed.
© Martin L. Puterman – Sauder School of Business
28
Download