Vous êtes sur la page 1sur 33

Time Series and Forecasting Lecture 4 with solutions

Moving averages and exponential


smoothing with solutions.
Objectives
By the end of this weeks work you should be able to:
briefly describe the use of smoothing methods to produce forecasts in a business
context;
use a simple average to produce a forecast and explain when it may be
appropriate to use this method;
use and briefly discuss moving averages and explain how changing the number of
observations used in the average affects the smoothing results;
explain when a moving average method may be appropriate for forecasting and
discuss its weaknesses;
explain the rationale of exponential smoothing;
describe when simple exponential smoothing may be appropriate and use this
method to produce forecasts either by a hand calculation or using Excel;
show that a simple exponential smoothing forecast is a weighted average of past
values of a time series which places greater emphasis on the most recent
observations;
explain how the value of the smoothing constant, , affects the forecast;
decide on a value for in a given situation and justify that choice.

Introduction
Imagine you are the manager of a large department store with hundreds of product
lines. You may need to produce forecasts for all of these products on a regular basis
weekly or monthly forecasts for instance. You could develop sophisticated models
to produce the forecasts for each product line but probably a quicker, less
sophisticated method will do the job just as well.
Time series smoothing methods are popular options in this type of situation for
producing forecasts. Smoothing methods use a form of weighted average of past
observations to smooth the up and down movements in the data it is a method
which smooths out short term variations or fluctuations in the data.
Sophisticated methods often require large data sets as they rely on estimating a
model to describe the time series and using this model to produce forecasts.
Smoothing methods can be used with much smaller data sets and are often the
method of choice in these situations.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 2

Smoothing
methods

Moving averages and exponential smoothing with solutions

We will be looking at four different smoothing methods in this module.


Moving averages a revision of ideas you will have encountered in a level 1
module.
Simple exponential smoothing.
Holts exponential smoothing
Winters (or Holt-Winters) exponential smoothing.
All of these methods are similar in the fact that they only need past observations of
the time series to produce a forecast. The appropriate method to use in a specific
situation will depend on the characteristics of the time series. Specifically:
Does the time series exhibit either an upward or a downward trend?
Is there a seasonal component evident in the time series?
So before starting to use one of the methods it is important that you complete an
initial exploratory data analysis using techniques such as time series plots.

Strategy for
producing
forecasts

The following steps can be followed to produce forecasts using smoothing methods.
1. Select an appropriate smoothing technique based on characteristics of the time
series evident in a time series plot for example.
2. If possible split the data into parts, an initialisation or fitting section and a test or
forecasting section.
3. Use the initialisation section to identify the exact form of the smoothing method
to use with the given data set.
4. Use the smoothing method to produce forecasts for the test section of the data and
evaluate the accuracy of these forecasts.
5. Make a decision to either use the method as it stands to produce the forecasts, or
modify the method or use another forecasting technique.

u The calculations associated with smoothing forecasts are easily computed by


hand, although it can become a little tedious. During the next two lectures you
will be performing the calculations by hand to ensure you develop a sound
understanding of the techniques. However, you will be expected to use EXCEL
to produce smoothing forecasts. Minitab and SPSS also produce forecasts for
smoothing methods but they do not enable you to demonstrate your
understanding of the techniques. For this reason you will be expected to use
EXCEL in the labs and for your coursework but you can still use Minitab etc as
a final check if you wish.

Notation

Time Series and Forecasting


2014/15

We will be using the following notation relating to forecasts during the next two
lectures. There is no standard notation associated with forecasting so you will see a
variety of different notations in text books referring to data and forecasts.

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Past data

Yt 3

Yt 2

Yt 1

Page 3

Current
time point

Forecasts of future values

Yt

Ft +1

Ft + 2

Ft +3

..

Yt is the most recent observation of a variable or time series.

Ft +1 is the forecast for one time point or period in the future etc.

Moving Averages
Simple averages

The easiest way of using the past observations in a data set to produce a forecast is to
just to use the average or mean of the previous observations as the forecast.

Example 1
Table 1 details the amount of petrol used each week for a company who operate a
fleet of vehicles for transporting disabled and elderly patients. Figure 1 shows a time
series plot for this data.

Does the plot in figure 1 indicate the presence of a trend or seasonal


component in the time series?
No trend component as the plot is constant in level.
No pattern repeating itself in cycles of fixed length so there is no seasonal
component.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 4

Moving averages and exponential smoothing with solutions

Table 1 Petrol usage for Spokane Transit Authority


Week (t)

Gallons ( Yt )

Week (t)

Gallons ( Yt )

Week (t)

Gallons ( Yt )

275

11

302

21

310

291

12

287

22

299

307

13

290

23

285

281

14

311

24

250

295

15

277

25

260

268

16

245

26

245

252

17

282

27

271

279

18

277

28

282

264

19

298

29

302

10

288

20

303

30

285

th

Data source: Hanke, Wichern and Reitsch. Business Forecasting (7 edition) Prentice Hall. Pg 100.

Figure 1 Petrol usage for Spokane Transit Authority.

310
300

Gallons

290
280
270
260
250
240
Week

Time Series and Forecasting


2014/15

10

20

30

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 5

To produce a simple average forecast for this time series we now need to decide on
an initialisation period say the first 28 observations.

Based on the first 28 observations produce a simple average forecast


for observation 29.
(275+291+307+.+271+282)/28 = 7874/28 = 281.21

What is the error associated with this forecast?


actual value forecast = 302-281.21 = 20.79

How would you now calculate a forecast for observation 30?


[(28*281.21)+302]/29 = 281.93

Now calculate a forecast for observation 31.


[(29*281.93)+285]/30 = 282.03

Would this method work if there were a significant trend in the series?
Explain your answer.
No. An average will tend to be in the middle of the range of the
observations from which it was calculated. Therefore, if there is upward
trend the average will always tend to be too low and if there is downward
trend it will tend to be too high.

A simple average uses all of the past observations to produce a forecast and places
equal weight or importance on all of the observations. This is only appropriate if the
time series is relatively stable - i.e. there is no trend or seasonal component in the
time series. The time series could be described as varying randomly about a constant
mean value the number of appointments per week at a dentist surgery with a fairly
constant patient base could be expected to have this characteristic.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 6

Moving averages

Moving averages and exponential smoothing with solutions

What if you are more interested in the most recent observations for the purposes of
producing a forecast? Placing equal importance on all past observations would no
longer be feasible. You may want to use the average of only the most recent
observations and use a moving average instead. The number of observations to be
used in computing each average is decided at the beginning of the exercise and then
stays the same for all subsequent forecasts. For example, we could decide that five
observations should be used to calculate each average, this means that the five most
recent observations are used to produce the forecast. As each new observation
becomes available a new mean is computed by adding the newest value and
dropping the oldest. You will have met this idea in either STX1110 or STX1210 at
level 1.
A moving average of order k is computed by

Ft +1 =

Yt + Yt 1 + Yt 2 + ....... + Yt ( k 1)
k

where

Ft +1 is the forecast
Yt is the actual value of the time series at time t
k is the number of observations used in the moving average.
So this forecast is just the arithmetic mean of the k most recent observations.

Does a moving average forecast place equal weight on all the


observations used in its calculation?
Ans: Yes

Example 2
Table 2 shows you the process of calculating moving averages of order 5 for the
transport company data used in example 1.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 7

Table 2 Moving average forecast (order 5) for the Spokane Transit Authority.
t

Gallons

(Yt )

Ft

et = (Yt Ft )

275

291

307

281

295

268

289.8

-21.8

252

288.4

-36.4

279

280.6

-1.6

264

275.0

-11.0

10

288

271.6

16.4

11

302

270.2

31.8

12

287

277.0

10.0

13

290

284.0

6.0

14

311

286.2

24.8

15

277

295.6

-18.6

16

245

293.4

-48.4

17

282

282.0

0.0

18

277

281.0

-4.0

19

298

278.4

19.6

20

303

275.8

27.2

21

310

281.0

29.0

22

299

294.0

5.0

23

285

297.4

-12.4

24

250

299.0

-49.0

25

260

289.4

-29.4

26

245

280.8

-35.8

27

271

267.8

3.2

28

282

262.2

19.8

29

302

30

285

The moving average forecast for observation 6 ( Y6 ) in table 2 is


289.9. Show that this is correct.
(275+291+307+281+295)/5 = 1449/5 = 289.8

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 8

Moving averages and exponential smoothing with solutions

Why are there no forecasts for time points 1 to 5?


Not enough data to produce moving average forecasts based on 5
observations.

Calculate the moving average forecast of order 5 for observation 29.


What is the error associated with this forecast?
(20+260+245+271+282)/5 = 1308/5 = 261.1
Error = 302-261.6 = 40.4

Calculate the forecasts for observations 30 and 31.


Observation 30 : Forecast = 272 , Observation 31: Forecast = 277

Using Excel to calculate moving average forecasts

Excel makes light work of all the repeat calculations involved in producing moving
average forecasts. The following notes take you through the steps in Excel, which
will produce the calculations presented in Table 2.
1. Open up a fresh worksheet in Excel and use the first row to explain the contents of
each column. In Figure 2 you will see that I have used the titles time, gallons,
forecast and error. I have then left a blank row before entering the data.
2. Enter the data into column B cells B3-B32

Calculating the
forecasts.

3. Highlight cell C8.


4. Use the function button as you were shown in week 2 to calculate the average of
the first 5 data points.
=AVERAGE(B3:B7)
This will calculate the average of the first 5 observations and, when you hit
return, puts the answer in cell C8. The worksheet should now look similar to the
one presented in Figure 2.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 9

Figure 2 using excel to produce moving average forecasts.

5. Copy cell C8 and paste it into cell C9. The value 288.4 now appears in cell C9
which is the average of the value in cells B4-B8. (Excel has automatically used
cells B4-B8 rather than B3-B7 as it uses relative cell referencing.)
6. Copy cell C8 into the remaining cells C10-C32.

Calculating the
errors.

Time Series and Forecasting


2014 / 2015

You were shown how to calculate errors in week 2. If you follow the instructions
detailed in the handout for week 2 you will be able to produce the absolute errors,
squared errors, percentage error and absolute percentage error with their relevant
summary statistics which can then be used for comparing different forecasting
methods. Your spreadsheet should look similar to Figure 3.

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 10

Moving averages and exponential smoothing with solutions


Figure 3 complete Excel analysis for petrol usage data.

Time Series and Forecasting


2014/15

In your own time check that you can produce the results in figure 3.

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 11

Using Minitab to calculate moving average forecasts


The same calculations can be produced in Minitab. As you do not need to enter the
formula for the moving average in Minitab you are not able to demonstrate your
understanding of the underlying calculations. As a result you will be expected to use
Excel on this module for moving averages but you can use Minitab to check your
answers or provide graphics if you wish. Moving averages can be calculated in
Minitab using Stat Time Series Moving average
Select the variable relating to the petrol usage and enter 5 for the MA (moving
average) length. Do not click the Center moving average box. Click generate
forecasts and indicate 1 by Number of forecasts.
Click the results option box and select a plot of predicted vs actual graphic and
the summary and results table. This will give the output shown in Figures 4 and
5. The last two columns of the summary table in figure 4 match the calculations
presented earlier in table 2.
Figure 4 Predicted vs actual time series plot for petrol usage.

Moving Average

330

Actual
Predicted

gallons

Forecast
Actual
Predicted
Forecast

280
Moving Average
Length:

230
0

10

20

MAPE:

7.503

MAD:

20.584

MSD:

622.149

30

Time

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 12

Moving averages and exponential smoothing with solutions


Figure 5 results table of order 5 moving average for petrol usage data.
Moving average
Data
Length
NMissing

gallons
30.0000
0

Moving Average
Length: 5
Accuracy Measures
MAPE:
7.503
MAD:
20.584
MSD: 622.149

Time Series and Forecasting


2014/15

Row

Period

gallons

MA

Predict

Error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

275
291
307
281
295
268
252
279
264
288
302
287
290
311
277
245
282
277
298
303
310
299
285
250
260
245
271
282
302
285

*
*
*
*
289.8
288.4
280.6
275.0
271.6
270.2
277.0
284.0
286.2
295.6
293.4
282.0
281.0
278.4
275.8
281.0
294.0
297.4
299.0
289.4
280.8
267.8
262.2
261.6
272.0
277.0

*
*
*
*
*
289.8
288.4
280.6
275.0
271.6
270.2
277.0
284.0
286.2
295.6
293.4
282.0
281.0
278.4
275.8
281.0
294.0
297.4
299.0
289.4
280.8
267.8
262.2
261.6
272.0

*
*
*
*
*
-21.8
-36.4
-1.6
-11.0
16.4
31.8
10.0
6.0
24.8
-18.6
-48.4
0.0
-4.0
19.6
27.2
29.0
5.0
-12.4
-49.0
-29.4
-35.8
3.2
19.8
40.4
13.0

Row
1

Period
31

Forecast
277

Lower
228.112

Upper
325.888

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 13

The final row of Figure 5 is the forecasts for observation 31. Does this
match the value you calculated earlier?
Ans ; Yes

What do the lower and upper values in this part of the output tell
you?
Ans: 95% confidence (or prediction) interval associaetd with the forecast)

In Figure 4 how well does the predicted moving average match the
actual data?

Ans; The peaks and troughs in the moving average forecast lag the peaks and
troughs in the actual data.
A major problem with moving average models is the fact that they are not very good
at predicting peaks and troughs in the data.

Choosing the value


for k.

If you are using a moving average forecast you need to make a judgement about
what value of k to use i.e. how many observations should you use when calculating
each average?

Can you remember anything from your level 1 module about the best
choice of k in a given situation?

Ans: If the data is seasonal the value of k should match the period of the
seasonal component. If the data is quarterly k=4 etc.

Figure 6 shows moving average forecasts for the transport company


data. The first graph is using a moving average of order 3 (i.e. k = 3)
and the second is using a moving average of order 8. What are the
differences in the predicted moving average forecasts in each graph?

Ans; k=3 results in a moving average which reflects the ups and dwons of the
data more whereas when k=8, the moving average forecast is smoother.
If k is small, greater emphasis is placed on more recent observations so
the moving average tracks changes in the data more closely.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 14

Moving averages and exponential smoothing with solutions


Figure 6 Moving average forecasts for petrol usage data.
Moving Average

Actual

330

Predicted
Forecast
Actual
Predicted
Forecast

gallons

310

290
Moving Average

270

Length:

250

10

20

MAPE:

6.489

MAD:

17.815

MSD:

483.881

30

Time

Moving Average

318

Actual

308

Predicted
Forecast

298

Actual
Predicted
Forecast

gallons

288
278
268

Moving Average

258

Length:

248
238
228
0

10

20

MAPE:

6.380

MAD:

17.563

MSD:

457.979

30

Time

A large value of k will have a greater smoothing effect on the data than a smaller
value. This is because a smaller value of k places more weight on recent observations
and as a result the moving average responds to and tracks changes more closely. So
a small value for k should be chosen when there are sudden changes in the series
whereas a larger value should be chosen when there are less fluctuations in the
series. If a moving average is being used with seasonal data such as quarterly or
monthly, the value of k should be chosen to match the length of the seasonal factor to
smooth out these effects. For example, for quarterly data a moving average of order
four, (k = 4) should be used.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Data with a trend.

Page 15

As with a simple average the moving average method does not cope well when there
is an upward or downward trend in the data. This is illustrated in Figure 7.
Figure 7 Moving average of order 3 for some fictitious data.

Moving Average

100

Actual
Predicted
Forecast

data

90

Actual
Predicted
Forecast

80

Moving Average

70

60

10

Length:

MAPE:

6.1745

MAD:

4.8056

MSD:

30.2130

15

Time

What is the nature of the trend in this data?

Ans: Upward

How well do the predicted values match the data?

Ans: The predicted values are too low.

Do you think the forecast is likely to be accurate? Explain your


answer.

Ans: No, the forecast is not likely to be accurate. It will probably be an


underestimate.

You can use Double moving averages to try and address these problems. You can
read about this in Hanke, Wichern and Reitsch, Business Forecasting (seventh
edition) page 104.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 16

Moving averages and exponential smoothing with solutions

Exponential Smoothing
Consider the time series plot in Figure 8. The initial observations seem to be
fluctuating about a constant value of around 55. However, the more recent
observations are showing a change in pattern and exhibiting an increase. As a result
the initial values of the time series bear little resemblance to the more recent
observations.
Figure 8 Time series plot of fictitious data.

80

data

70

60

50
Index

10

15

20

It could be argued that, for forecasting purposes, the most recent observations
contain the most relevant information and as a result they should be given more
importance, or weight, in the calculation of the forecast. This is what exponential
smoothing achieves. The forecast value at any time t is a weighted average of all the
available previous values. The most recent observations are given the highest
weights and earlier observations are given lower weights. As a result the most recent
observations have more influence over the forecast than earlier observations.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Simple exponential
smoothing.

Page 17

Simple exponential smoothing is appropriate for producing forecasts when there is


no trend or seasonal component in the data. The formula for producing a simple
exponential smoothing forecast is:

Ft +1 = Yt + (1 ) Ft

Equation 1

Ft +1 is the forecast at time t+1

is called the smoothing constant and must have a value between 0 and 1
(0< <1).
Yt is the actual value of the time series at time t.
Ft is the forecast at time t (or smoothed value at time t).
So the forecast at time t+1 can be thought of as weighted average of the observation
at time t and the old forecast for the observation at time t.

Error correction
form

If we take equation 1 and rearrange it so that all the terms involving are brought
together we get the following.

Ft +1 = Yt + (1 ) Ft
Ft +1 = Yt + Ft Ft
Ft +1 = Ft + (Yt Ft )
Ft +1 = Ft + t

Equation 2

In equation 2, t is the difference between the actual observation at time t and the
forecast at time t i.e. t is the error associated with the forecast at time t.
From this form of the forecast equation we can see that the exponential smoothing
forecast learns from past errors. The forecast at time t+1 ( Ft +1 ) is simply the old
forecasts ( Ft ) adjusted by times the error in this forecast. So exponential
smoothing is a procedure for revising a forecast in the light of more recent
experience.

If the error at time t was positive, was the forecast at time t higher or
lower than the actual observation?
Ans: Lower

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 18

Moving averages and exponential smoothing with solutions

If the error at time t is positive, is the forecast at time t+1 higher or


lower than the forecast at time t?
Ans: Using equation 2, if and t are both positive the next forecast will be
higher than the last one. A positive error indicates that the last forecast
was too low so at the next stage it is increased to adjust for this mistake.

What happens if the error at time t is negative?


Ans: The next forecast is reduced.

This error correction form of the forecast equation is very easy to use. All we need
to produce the forecast at the next time point is the actual value for this period and
the forecast value for this period. However all the past values of the time series are
still included in the forecast which the next activity demonstrates.

By substituting for Ft in equation 1 show that all past values of the


time series are included in the calculation of the forecast Ft +1 .
This was covered in the lecture and is not reproduced here. See Gary if
you have difficulty completing this activity.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 19

You should have produced workings something similar to the following.

Ft +1 = Yt + (1 ) Ft
Ft +1 = Yt + (1 )[Yt 1 + (1 ) Ft 1 ] = Yt + (1 )Yt 1 + (1 ) 2 Ft 1
By repeatedly substituting for Ft 1 etc it is relatively easy to show that

Ft +1 = Yt + (1 )Yt 1 + (1 ) 2 Yt 2 + (1 ) 3 Yt 3 + .....

Equation 3

If =0.6 equation 3 becomes

Ft +1 = 0.6Yt + 0.6(1 0.6)Yt 1 + 0.6(1 0.6) 2 Yt 2 + 0.6(1 0.6) 3 Yt 3 + .....

Ft +1 = 0.6Yt + 0.24Yt 1 + 0.096Yt 2 + 0.0384Yt 3 + .....

!
!

Equation 4

In your own time check that these coefficients are correct.


In equation 4, which of the past values of the time series has the
greatest influence on the forecast Ft +1 .
Ans: The most recent observation Yt as it has the biggest coefficient.

What would the forecast Ft +1 be if =1?


Ans: Ft +1 = Yt , tomorrow is the same as today prinicple.

What would the forecast Ft +1 be if =0?


Ans: Ft +1 = Ft . The forecast does not depend on the data. Once youve
guessed or evaluated the first forecast all subsequent forecasts will be the
same.

Consider the values of the weights for various values of presented


in table 3. How does the dependence of Ft +1 on past values of the
time series change as varies between 0 and 1?
See the comment under table 3.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 20

Moving averages and exponential smoothing with solutions


Table 3 Comparison of weights of past observations for various
values of in simple exponential smoothing.
Observation

Weight

=0.1

=0.5

=0.7

Yt

0.1

0.5

0.7

(1 )Yt 1

(1 )

0.09

0.25

0.21

(1 )2 Yt 2

(1 )2

0.081

0.125

0.063

(1 )3 Yt 3

(1 )3

0.073

0.0625

0.0189

If is chosen close to 1, recent values of the time series are weighted heavily
relative to those of the distant past. If is chosen close to 0, the values of the time
series in the past are given weights comparable to those given to recent values.
Regardless of the values of the weights will tend to sum to 1.

Choosing a value
for .

The choice of the value for depends on how much you want the current
observation to influence the forecast. When is close to one the new forecast will
contain a substantial adjustment for any error in the previous forecast. If is close
to zero, the new forecast will be very similar to the old one. As a guide choose
values of close to zero if the series has a great deal of random variation and you
want to minimise the impact of this variation on the forecast. Choose values close to
1 if you want the forecast to be influenced by recent changes in the actual values. In
practice the value of is often taken to be between 0.05 and 0.5 with 0.3 being a
good starting point. In judging which is the best value of to use you should
choose a value which minimises the root mean square error (RMSE) as shown in the
following example.

Example 3
The number of calls received on a telephone helpline for the last 7 days are, 96, 93,
97, 96, 102, 105 and 99. The trend for this data can be assumed to be negligible.
Using a smoothing constant of 0.1 evaluate the smoothing forecast for the number of
calls received on day 8.
This is quite a small data set so we will not produce an exploratory time series plot to
check the overall characteristics of the data. Normally you would produce a time
series plot first use it to establish if there is a trend or seasonal component in the
data.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 21

We now need to initialize the forecasting process. There are a number of ways that
you can do this but we will start off by initially setting the forecast for the second
observation, F2 , to be equal to the first observation 96.

What is the error, 2 , associated with this forecast?


Ans: 93-96=-3

If = 0.1 we can now calculate the forecast for the time point 3, F3 , using

F3 = Y2 + (1 )F2 = (0.1 93) + [(1 0.1) 96] = 9.3 + 86.4 = 95.7


Alternatively we can use the error correction form of the model to evaluate the
forecast using

F3 = F2 + 2 = 96 + (0.1 3) = 95.7
The forecasts, or smoothed values, for the whole data set, along with their associated
errors are presented in table 4.
Table 4 Simple exponential smoothing forecast for number of calls
received on a telephone help line.

!
!

time

data (number of calls)

forecast or smoothed value

error

96

93

96

-3

97

95.7

1.3

96

95.83

0.17

102

95.847

6.153

105

96.462

8.538

99

97.316

1.684

In your own time verify that these values are correct using a hand
calculation.
Evaluate the forecast of the number of calls to the helpline on day 8.
Ans: (0.1*99)+(1-0.1)*(97.316) = 97.4844

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 22

Moving averages and exponential smoothing with solutions


The root mean square error for this forecasting procedure is evaluated using

RMSE =

(Y

Y2
n

t2
n

Verify that the RMSE for the calculations in table 4 is 4.55 (to 2 dp).

124.3112 = 4.55
6

Using Excel to calculate simple exponential smoothing forecasts.


1. Open up a fresh worksheet in Excel and use the first row to explain the contents
of each column. In Figure 9 you will see that I have used the titles time, calls,
forecast and error.
2. Enter the data into column B cells B3-B9
3. Initialize the forecasting process by entering the first observation (96) as the
forecast for time point 2, F2 . That is, put the value 96 into cell C4 of the
spreadsheet as shown in Figure 9.
Figure 9

4. Evaluate the forecast F3 by highlighting the cell C5 and entering the formula
=0.1*B4+(1-0.1)*C4

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 23

5. Copy cell C5 into cells C6 to C9 to give the results in figure 10. (Notice that I
have formatted column C5 to show 2 dp.)
Figure 10

6. You can calculate errors and their relevant summary measures as detailed in the
handout for week 2. Your final spreadsheet should look similar to the one
presented in figure 11.

Figure 11

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 24

Changing the value


of

Moving averages and exponential smoothing with solutions

Once you have completed the spreadsheet for one value of it is easy to update it
using a different value for the smoothing constant. The value of in the above
exercise was 0.1 - suppose we want to see what happens to the RMSE if we use
=0.4. If you go back into cell C5 the expression used to calculate C5 is in the
formula bar. Change the 0.1 to a 0.4 in this expression. Then copy cell C5 into cells
C6 to C9. You will find that the spreadsheet updates itself and the RMSE is 4.108.

Table 4 shows the value of RMSE for various values of for the
telephone data in example 3. Based on this information which value of
should be used for producing forecasts.
Ans: The RMSE is lowest when =0.6
Table 4 Comparison of RMSE for varying values of for the
telephone data.

(Y Y )

Time Series and Forecasting


2014/15

(Y Y )

RMSE =

0.1

124.3063

4.55

0.2

114.1912

4.36

0.3

106.456

4.21

0.4

101.2615

4.18

0.5

98.3955

4.05

0.6

97.48711

4.03

0.7

98.15374

4.04

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 25

Concluding comments.
This lecture has demonstrated that moving average methods are a quick way of
generating forecasts, particularly if you exploit the features of a spreadsheet system
such as Excel. They can be used with small data sets which gives them an
advantage over some more sophisticated methods and they are quite simple to use.
However, they are limited in the sense that the forecasts tend to lag behind the actual
data and the methods we have considered in this lecture cannot adjust for trend in the
data.
Exponential smoothing assumes the continuation of a historical pattern into the
future. It would be useful to develop a way of measuring if this pattern has changed
so that we can reassess our forecasting procedure. A tracking signal is one way of
monitoring this change. We will not consider tracking signals in this module but you
can read about it in Hanke, Wichern and Reitsch.

Moving averages and exponential smoothing lecture check list


The following list details the analyses and discussions you should be able to
complete if you have covered and understood all of this weeks work.
You should be able to:
calculate moving average forecast either by hand or using Excel;
explain how the period of the moving average affects the resulting forecasts;
calculate simple exponential smoothing forecasts either by hand or in Excel;
explain what is meant by the error correction form of a simple exponential
smoothing forecast;
show that all the past values of a time series are included in a simple
exponential smoothing forecast;
explain how the weighting of past values in the time series varies as the value
of the smoothing constant changes;
select a value of to use in simple exponential smoothing and justify this
choice by referring to appropriate error summaries;
use Minitab to check results of moving average forecasts and simple
exponential smoothing forecasts;
explain why moving averages and simple exponential smoothing forecasts are
not appropriate if the time series has a trend component.

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 26

Moving averages and exponential smoothing with solutions

Lab exercises
Exercise 1

a) Use Excel to produce the moving average forecasts of the petrol usage
data as shown in figure 3.
b) Use Excel to produce the simple exponential smoothing forecasts for the
telephone data as shown in figure 11.

Exercise 2

For this exercise we will return to the bread data which we have used in previous
weeks. You should already have this in an Excel worksheet as you worked on this
data in week 2. If not, copy the data from the Minitab worksheet (bread.mtw) in the
data files area of the OASIS page for this module.
a) Calculate a moving average forecast of period 3 for this data.
b) Calculate the values of the mean error (ME), mean absolute error
(MAE), mean squared error (MSE), root mean squared error (RMSE),
mean percentage error (MPE) and mean absolute percentage error
(MAPE).
c) Produce a time series plot of the actual and forecast values on the same
graph.
d) What would be the value of the forecast for time point 31?
e) Repeat parts (a)-(d) using a moving average of period 7.
f) Which moving average period would you use if you wanted to limit the
impact of the short-term fluctuations on the resulting forecasts? Explain
your answer.
g) How do the answers obtained for this exercise compare with those of
exercise 3 in week 2?

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Exercise 3

Page 27

For this exercise we will return to the Microsoft stock closing prices data which we
have used in previous weeks. You should already have this in an Excel worksheet as
you worked on this data in week 2. If not, copy the data from the Minitab worksheet
(msft.mtw) in the data files area of the OASIS page for this module.
The Microsoft stock closing prices data consists of five time series. Use the close
data when doing the following exercises:
a) Use Excel to calculate the simple exponential smoothing forecast for the
data using a smoothing constant value =0.1. In addition, calculate
appropriate error summary statistics.
b) Repeat part (a) using a smoothing constant value, =0.4.
c) Do you prefer the forecasts produced in part (a) or part (b)? Explain
your answer.
d) Use the single exponential smoothing routine in Minitab to produce
forecasts for the close data. Under weight to use in smoothing choose
optimise then click OK. How does this compare with your answers to
parts (a) and (b)? What do you think this routine in Minitab is doing?

Exercise 4

Time Series and Forecasting


2014 / 2015

Use moving averages and simple exponential smoothing to forecast the remaining
time series in the Microsoft stock closing prices data set.

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 28

Moving averages and exponential smoothing with solutions

Solutions to lab exercises

Exercise 1
Refer to the lecture notes.

Exercise 2
a) See table headed Moving Average Period 3 on the next page.
b)
ME

0.17

MAE

2.17

MSE

7.12

RMSE

2.67

MPE

0.00

MAPE

0.04

c)

Sales and moving average forecasts of period 3

sales

56
54
52
50
48

Series1
Series2

28

25

22

19

16

13

10

46
44
42
day

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 29

Moving Average period 3


time

sales forecast (p3) error

48

49

48

48

48.3333

-0.3333 0.33

0.11

-0.69% 0.69%

49

48.3333

0.6667

0.67

0.44

1.36%

54

48.3333

5.6667

5.67

32.11

10.49% 10.49%

49

50.3333

-1.3333 1.33

1.78

-2.72% 2.72%

50

50.6667

-0.6667 0.67

0.44

-1.33% 1.33%

47

51.0000

-4.0000 4.00

16.00

-8.51% 8.51%

10

48

48.6667

-0.6667 0.67

0.44

-1.39% 1.39%

11

53

48.3333

4.6667

21.78

8.81%

12

47

49.3333

-2.3333 2.33

5.44

-4.96% 4.96%

13

53

49.3333

3.6667

13.44

6.92%

14

50

51.0000

-1.0000 1.00

1.00

-2.00% 2.00%

15

49

50.0000

-1.0000 1.00

1.00

-2.04% 2.04%

16

51

50.6667

0.3333

0.33

0.11

0.65%

17

48

50.0000

-2.0000 2.00

4.00

-4.17% 4.17%

18

52

49.3333

2.6667

2.67

7.11

5.13%

19

48

50.3333

-2.3333 2.33

5.44

-4.86% 4.86%

20

49

49.3333

-0.3333 0.33

0.11

-0.68% 0.68%

21

48

49.6667

-1.6667 1.67

2.78

-3.47% 3.47%

22

47

48.3333

-1.3333 1.33

1.78

-2.84% 2.84%

23

50

48.0000

2.0000

2.00

4.00

4.00%

4.00%

24

53

48.3333

4.6667

4.67

21.78

8.81%

8.81%

25

52

50.0000

2.0000

2.00

4.00

3.85%

3.85%

26

47

51.6667

-4.6667 4.67

21.78

-9.93% 9.93%

27

50

50.6667

-0.6667 0.67

0.44

-1.33% 1.33%

28

47

49.6667

-2.6667 2.67

7.11

-5.67% 5.67%

29

52

48.0000

4.0000

4.00

16.00

7.69%

7.69%

30

51

49.6667

1.3333

1.33

1.78

2.61%

2.61%

0.17

2.17

7.12

0.00

0.04

average
RMSE

Time Series and Forecasting


2014 / 2015

abs error sq error

4.67

3.67

% error abs % error

1.36%

8.81%

6.92%

0.65%

5.13%

2.668209

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 30

Moving averages and exponential smoothing with solutions


d) Forecast of observation 31 is

47 + 52 + 51
= 50
3
e)
See table headed Moving Average Period 7 on the next page.

Sales and moving average forecast (period 7)


56
54
52
50

Series1

For

Series2

48
46
44
1

9 11 13 15 17 19 21 23 25 27 29

f) To limit the impact of short-term fluctuations on the forecast choose a larger value
of k, i.e. k=7. This has the effect of smoothing out the fluctuations in the data.

Time Series and Forecasting


2014/15

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

time sales forecast (p7) error

2014 / 2015

abs error sq error

% error abs % error

48

49

48

48

49

54

49

50

49.2857

0.7143

0.71

0.51

1.43%

47

49.5714

-2.5714 2.57

6.61

-5.47% 5.47%

10

48

49.2857

-1.2857 1.29

1.65

-2.68% 2.68%

11

53

49.2857

3.7143

13.80

7.01%

12

47

50.0000

-3.0000 3.00

9.00

-6.38% 6.38%

13

53

49.7143

3.2857

3.29

10.80

6.20%

6.20%

14

50

49.5714

0.4286

0.43

0.18

0.86%

0.86%

15

49

49.7143

-0.7143 0.71

0.51

-1.46% 1.46%

16

51

49.5714

1.4286

1.43

2.04

2.80%

17

48

50.1429

-2.1429 2.14

4.59

-4.46% 4.46%

18

52

50.1429

1.8571

1.86

3.45

3.57%

19

48

50.0000

-2.0000 2.00

4.00

-4.17% 4.17%

20

49

50.1429

-1.1429 1.14

1.31

-2.33% 2.33%

21

48

49.5714

-1.5714 1.57

2.47

-3.27% 3.27%

22

47

49.2857

-2.2857 2.29

5.22

-4.86% 4.86%

23

50

49.0000

1.0000

1.00

1.00

2.00%

2.00%

24

53

48.8571

4.1429

4.14

17.16

7.82%

7.82%

25

52

49.5714

2.4286

2.43

5.90

4.67%

4.67%

26

47

49.5714

-2.5714 2.57

6.61

-5.47% 5.47%

27

50

49.4286

0.5714

0.57

0.33

1.14%

28

47

49.5714

-2.5714 2.57

6.61

-5.47% 5.47%

29

52

49.4286

2.5714

2.57

6.61

4.95%

4.95%

30

51

50.1429

0.8571

0.86

0.73

1.68%

1.68%

Mean

0.0497

1.9503

4.8305

-0.0008 0.0392

RMSE

Time Series and Forecasting

Page 31

3.71

1.43%

7.01%

2.80%

3.57%

1.14%

2.197845

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Page 32

Moving averages and exponential smoothing with solutions

Exercise 3
b) The first 10 rows of the calculations for = 0.1 are presented below.

time close

73.4375

69.875

forecast (0.1) error

73.4375

abs error sq error

% error abs % error

-3.5625 3.5625

12.69141 -5.10% 5.10%

70.5625 73.0813

-2.5188 2.51875

6.344102 -3.57% 3.57%

70.4375 72.8294

-2.3919 2.391875 5.721066 -3.40% 3.40%

71.125

72.5902

-1.4652 1.465188 2.146774 -2.06% 2.06%

69.8125 72.4437

-2.6312 2.631169 6.923049 -3.77% 3.77%

67.8125 72.1806

-4.3681 4.368052 19.07988 -6.44% 6.44%

66.1875 71.7437

-5.5562 5.556247 30.87188 -8.39% 8.39%

67.875

-3.3131 3.313122 10.97678 -4.88% 4.88%

10

68.8125 70.8568

71.1881

-2.0443 2.04431

4.179203 -2.97% 2.97%

c) The first 10 rows of the calculations when = 0.4 are

time close

Time Series and Forecasting


2014/15

73.4375

69.875

forecast (0.4) error

73.4375

abs error sq error

% error abs % error

-3.5625 3.5625

12.69141 -5.10% 5.10%

70.5625 72.0125

-1.4500 1.45

2.1025

70.4375 71.4325

-0.9950 0.995

0.990025 -1.41% 1.41%

71.125

0.0905

0.00819

69.8125 71.0707

-1.2582 1.2582

1.583067 -1.80% 1.80%

67.8125 70.5674

-2.7549 2.75492

7.589584 -4.06% 4.06%

66.1875 69.4655

-3.2780 3.277952 10.74497 -4.95% 4.95%

67.875

-0.2793 0.279271 0.077992 -0.41% 0.41%

10

68.8125 68.0426

71.0345

68.1543

0.7699

0.0905

-2.05% 2.05%

0.13%

0.769937 0.592803 1.12%

0.13%

1.12%

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Moving averages and exponential smoothing with solutions

Page 33

d) A comparison of the error measurements is as follows

Error measure

=0.1

=0.4

MAE

3.9047

1.8402

RMSE

4.4766

2.34

MAPE

0.0544

0.0259

The forecasts in part c) with =0.4 are preferable as the error measures are
consistently smaller than when =-0.1.
e) This routine in Minitab produces a result which says that the value of the
smoothing constant, , is 0.955. The RMSE = 3.36208 = 1.8336 and the MAE
= 1.44109. Both the RMSE and MAE are lower than those calculated in parts (b)
and (c). This routine in Mi

Time Series and Forecasting


2014 / 2015

Dr Cathy Minett-Smith and Gary Hearne


Middlesex University Business School

Vous aimerez peut-être aussi