MSO S04_Exponential Smoothing With Solutions

34
 Time Series a nd Forecasting Lecture 4 – with so lutions Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne 2014/15 Middlesex University Business School Moving averages and exponential smoothing – with solutions. By the end of this weeks work you should be able to:   briefly describ e the use of smoot hing methods to produce forecas ts 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 it’s 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. 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 mo nthly forecasts f or instance. You could dev elop 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 f orecasts. Smoothing meth ods use a form o f weighted averag e 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. Objectives Introduction

description

dasdasdasda

Transcript of MSO S04_Exponential Smoothing With Solutions

  • Time Series and Forecasting Lecture 4 with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Moving averages and exponential smoothing with solutions.

    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.

    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.

    Objectives

    Introduction

  • Page 2 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    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.

    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.

    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.

    Smoothing methods

    Strategy for producing forecasts

    Notation

  • Moving averages and exponential smoothing with solutions Page 3

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    Past data Current time point

    Forecasts of future values

    . 3tY 2tY 1tY tY 1+tF 2+tF 3+tF ..

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

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

    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.

    Moving Averages

    Simple averages

  • Page 4 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Table 1 Petrol usage for Spokane Transit Authority

    Week (t) Gallons ( tY ) Week (t) Gallons ( tY ) Week (t) Gallons ( tY )

    1 275 11 302 21 310

    2 291 12 287 22 299

    3 307 13 290 23 285

    4 281 14 311 24 250

    5 295 15 277 25 260

    6 268 16 245 26 245

    7 252 17 282 27 271

    8 279 18 277 28 282

    9 264 19 298 29 302

    10 288 20 303 30 285

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

    Figure 1 Petrol usage for Spokane Transit Authority.

    10 20 30

    240

    250

    260

    270

    280

    290

    300

    310

    Week

    Gallons

  • Moving averages and exponential smoothing with solutions Page 5

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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.

  • Page 6 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    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

    1 2 ( 1)1

    .......t t t t kt

    Y Y Y YF

    k

    +

    + + + +=

    where

    1+tF is the forecast

    tY 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.

    Moving averages

  • Moving averages and exponential smoothing with solutions Page 7

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

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

    t Gallons )( tY tF )( ttt FYe =

    1 275 * *

    2 291 * *

    3 307 * *

    4 281 * *

    5 295 * *

    6 268 289.8 -21.8

    7 252 288.4 -36.4

    8 279 280.6 -1.6

    9 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 ( 6Y ) in table 2 is 289.9. Show that this is correct.

    (275+291+307+281+295)/5 = 1449/5 = 289.8

  • Page 8 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    ! 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

    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

    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.

    @ Using Excel to calculate moving average forecasts

    Calculating the forecasts.

  • Moving averages and exponential smoothing with solutions Page 9

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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.

    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.

    Calculating the errors.

  • Page 10 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Figure 3 complete Excel analysis for petrol usage data.

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

  • Moving averages and exponential smoothing with solutions Page 11

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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 -

    StatTime SeriesMoving 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.

    @ Using Minitab to calculate moving average forecasts

    Actual

    Predicted

    Forecast Actual Predicted Forecast

    3020100

    330

    280

    230

    gallo

    ns

    Time

    MSD:MAD:MAPE:

    Length:Moving Average

    622.149 20.584 7.503

    5

    Moving Average

  • Page 12 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Figure 5 results table of order 5 moving average for petrol usage data. Moving average Data gallons Length 30.0000 NMissing 0 Moving Average Length: 5 Accuracy Measures MAPE: 7.503 MAD: 20.584 MSD: 622.149 Row Period gallons MA Predict Error 1 1 275 * * * 2 2 291 * * * 3 3 307 * * * 4 4 281 * * * 5 5 295 289.8 * * 6 6 268 288.4 289.8 -21.8 7 7 252 280.6 288.4 -36.4 8 8 279 275.0 280.6 -1.6 9 9 264 271.6 275.0 -11.0 10 10 288 270.2 271.6 16.4 11 11 302 277.0 270.2 31.8 12 12 287 284.0 277.0 10.0 13 13 290 286.2 284.0 6.0 14 14 311 295.6 286.2 24.8 15 15 277 293.4 295.6 -18.6 16 16 245 282.0 293.4 -48.4 17 17 282 281.0 282.0 0.0 18 18 277 278.4 281.0 -4.0 19 19 298 275.8 278.4 19.6 20 20 303 281.0 275.8 27.2 21 21 310 294.0 281.0 29.0 22 22 299 297.4 294.0 5.0 23 23 285 299.0 297.4 -12.4 24 24 250 289.4 299.0 -49.0 25 25 260 280.8 289.4 -29.4 26 26 245 267.8 280.8 -35.8 27 27 271 262.2 267.8 3.2 28 28 282 261.6 262.2 19.8 29 29 302 272.0 261.6 40.4 30 30 285 277.0 272.0 13.0 Row Period Forecast Lower Upper 1 31 277 228.112 325.888

  • Moving averages and exponential smoothing with solutions Page 13

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    ! 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.

    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.

    Choosing the value for k.

  • Page 14 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Figure 6 Moving average forecasts for petrol usage data.

    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.

    Actual

    Predicted

    Forecast Actual Predicted Forecast

    0 10 20 30

    250

    270

    290

    310

    330

    gallo

    ns

    Time

    Moving AverageLength:

    MAPE:MAD:MSD:

    3

    6.489 17.815483.881

    Moving Average

    Actual

    Predicted

    Forecast Actual Predicted Forecast

    0 10 20 30

    228

    238

    248

    258

    268

    278

    288

    298

    308

    318

    gallo

    ns

    Time

    Moving AverageLength:

    MAPE:MAD:MSD:

    8

    6.380 17.563457.979

    Moving Average

  • Moving averages and exponential smoothing with solutions Page 15

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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.

    ! 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.

    Data with a trend.

    Actual

    Predicted

    Forecast Actual Predicted Forecast

    0 5 10 15

    60

    70

    80

    90

    100da

    ta

    Time

    Moving AverageLength:

    MAPE:MAD:MSD:

    3

    6.1745 4.805630.2130

    Moving Average

  • Page 16 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    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.

    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.

    Exponential Smoothing

    5 10 15 20

    50

    60

    70

    80

    Index

    data

  • Moving averages and exponential smoothing with solutions Page 17

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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:

    ttt FYF )1(1 +=+ Equation 1

    1+tF is the forecast at time t+1

    is called the smoothing constant and must have a value between 0 and 1 (0

  • Page 18 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    ! 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 tF in equation 1 show that all past values of the time series are included in the calculation of the forecast 1+tF .

    This was covered in the lecture and is not reproduced here. See Gary if you have difficulty completing this activity.

  • Moving averages and exponential smoothing with solutions Page 19

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    You should have produced workings something similar to the following.

    ttt FYF )1(1 +=+

    12

    1111 )1()1(])1()[1( + ++=++= ttttttt FYYFYYF

    By repeatedly substituting for 1tF etc it is relatively easy to show that

    .....)1()1()1( 33

    22

    11 ++++= + ttttt YYYYF Equation 3

    If =0.6 equation 3 becomes

    .....)6.01(6.0)6.01(6.0)6.01(6.06.0 33

    22

    11 ++++= + ttttt YYYYF

    .....0384.0096.024.06.0 3211 ++++= + ttttt YYYYF 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 1+tF .

    Ans: The most recent observation Yt as it has the biggest coefficient.

    ! What would the forecast 1+tF be if =1? Ans: 1+tF = tY , tomorrow is the same as today prinicple.

    ! What would the forecast 1+tF be if =0? Ans: 1+tF = tF . 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 1+tF on past values of the time series change as varies between 0 and 1?

    See the comment under table 3.

  • Page 20 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

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

    Observation Weight =0.1 =0.5 =0.7

    tY 0.1 0.5 0.7

    ( ) 11 tY ( ) 1 0.09 0.25 0.21

    ( ) 221 tY ( )

    21 0.081 0.125 0.063

    ( ) 331 tY ( )

    31 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.

    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.

    Choosing a value for .

  • Moving averages and exponential smoothing with solutions Page 21

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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, 2F , to be equal to the first observation 96.

    ! What is the error, 2 , associated with this forecast? Ans: 93-96=-3

    If 1.0= we can now calculate the forecast for the time point 3, 3F , using

    ( ) ( ) ( )[ ] 7.954.863.9961.01931.01 223 =+=+=+= FYF

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

    ( ) 7.9531.096223 =+=+= FF

    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

    1 96 * *

    2 93 96 -3

    3 97 95.7 1.3

    4 96 95.83 0.17

    5 102 95.847 6.153

    6 105 96.462 8.538

    7 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

  • Page 22 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

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

    ( )nn

    YYRMSE tt

    22

    2 =

    =

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

    55.463112.124 =

    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, 2F . That is, put the value 96 into cell C4 of the spreadsheet as shown in Figure 9.

    Figure 9

    4. Evaluate the forecast 3F by highlighting the cell C5 and entering the formula

    =0.1*B4+(1-0.1)*C4

    @ Using Excel to calculate simple exponential smoothing forecasts.

  • Moving averages and exponential smoothing with solutions Page 23

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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

  • Page 24 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    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.

    ( )2tt YY ( )nYYRMSE tt

    2=

    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

    Changing the value of

  • Moving averages and exponential smoothing with solutions Page 25

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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.

    Concluding comments.

  • Page 26 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Lab exercises

    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.

    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?

    Exercise 1

    Exercise 2

  • Moving averages and exponential smoothing with solutions Page 27

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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?

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

    Exercise 3

    Exercise 4

  • Page 28 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    Refer to the lecture notes.

    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)

    Solutions to lab exercises

    Exercise 1

    Exercise 2

    Sales and moving average forecasts of period 3

    4244464850525456

    1 4 7 10 13 16 19 22 25 28

    day

    sale

    s Series1Series2

  • Moving averages and exponential smoothing with solutions Page 29

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    Moving Average period 3

    time sales forecast (p3) error abs error sq error % error abs % error

    1 48

    2 49

    3 48

    4 48 48.3333 -0.3333 0.33 0.11 -0.69% 0.69%

    5 49 48.3333 0.6667 0.67 0.44 1.36% 1.36%

    6 54 48.3333 5.6667 5.67 32.11 10.49% 10.49%

    7 49 50.3333 -1.3333 1.33 1.78 -2.72% 2.72%

    8 50 50.6667 -0.6667 0.67 0.44 -1.33% 1.33%

    9 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 4.67 21.78 8.81% 8.81%

    12 47 49.3333 -2.3333 2.33 5.44 -4.96% 4.96%

    13 53 49.3333 3.6667 3.67 13.44 6.92% 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% 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% 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%

    average 0.17 2.17 7.12 0.00 0.04

    RMSE 2.668209

  • Page 30 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    d) Forecast of observation 31 is

    503

    515247=

    ++

    e)

    See table headed Moving Average Period 7 on the next page.

    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.

    Sales and moving average forecast (period 7)

    44

    46

    48

    50

    52

    54

    56

    1 3 5 7 9 11 13 15 17 19 21 23 25 27 29

    Series1Series2

    For

  • Moving averages and exponential smoothing with solutions Page 31

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    time sales forecast (p7) error abs error sq error % error abs % error

    1 48

    2 49

    3 48

    4 48

    5 49

    6 54

    7 49

    8 50 49.2857 0.7143 0.71 0.51 1.43% 1.43%

    9 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 3.71 13.80 7.01% 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% 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% 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% 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 2.197845

  • Page 32 Moving averages and exponential smoothing with solutions

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014/15 Middlesex University Business School

    b) The first 10 rows of the calculations for 1.0= are presented below.

    time close forecast (0.1) error abs error sq error % error abs % error

    1 73.4375

    2 69.875 73.4375 -3.5625 3.5625 12.69141 -5.10% 5.10%

    3 70.5625 73.0813 -2.5188 2.51875 6.344102 -3.57% 3.57%

    4 70.4375 72.8294 -2.3919 2.391875 5.721066 -3.40% 3.40%

    5 71.125 72.5902 -1.4652 1.465188 2.146774 -2.06% 2.06%

    6 69.8125 72.4437 -2.6312 2.631169 6.923049 -3.77% 3.77%

    7 67.8125 72.1806 -4.3681 4.368052 19.07988 -6.44% 6.44%

    8 66.1875 71.7437 -5.5562 5.556247 30.87188 -8.39% 8.39%

    9 67.875 71.1881 -3.3131 3.313122 10.97678 -4.88% 4.88%

    10 68.8125 70.8568 -2.0443 2.04431 4.179203 -2.97% 2.97%

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

    time close forecast (0.4) error abs error sq error % error abs % error

    1 73.4375

    2 69.875 73.4375 -3.5625 3.5625 12.69141 -5.10% 5.10%

    3 70.5625 72.0125 -1.4500 1.45 2.1025 -2.05% 2.05%

    4 70.4375 71.4325 -0.9950 0.995 0.990025 -1.41% 1.41%

    5 71.125 71.0345 0.0905 0.0905 0.00819 0.13% 0.13%

    6 69.8125 71.0707 -1.2582 1.2582 1.583067 -1.80% 1.80%

    7 67.8125 70.5674 -2.7549 2.75492 7.589584 -4.06% 4.06%

    8 66.1875 69.4655 -3.2780 3.277952 10.74497 -4.95% 4.95%

    9 67.875 68.1543 -0.2793 0.279271 0.077992 -0.41% 0.41%

    10 68.8125 68.0426 0.7699 0.769937 0.592803 1.12% 1.12%

    Exercise 3

  • Moving averages and exponential smoothing with solutions Page 33

    Time Series and Forecasting Dr Cathy Minett-Smith and Gary Hearne

    2014 / 2015 Middlesex University Business School

    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 = 8336.136208.3 = and the MAE = 1.44109. Both the RMSE and MAE are lower than those calculated in parts (b) and (c). This routine in Mi