Forecasting Tutorial Script
Forecasting Tutorial Script
Forecasting is one of the most critical activities in management. Forecasting is used to predict future
demands, future customers, and future cost levels, among other key figures. Forecasting data is used in
planning. Imagine a company like apple and the iphone 4. The company needs to forecast the future
sales of the product in order to decide how many iphones to produce. A wrong forecasting has
disastrous consequences. If Apple produces too many iphones, the company will lose money. On the
other hand, if Apple does not produce enough iphones, the company will lose customers. Finally,
forecasting is one of the activities in which companies put more effort. Notice, that most planning
decisions are based on forecasting figures (i.e., hiring or letting workers go, borrowing money, etc.)
There are many different forecasting techniques. The objectives of this tutorial are to introduce the
reader to forecasting and to present the most popular forecasting methods. The method covered in this
tutorial are:
Naïve method
Moving average
Forecasting error (Mean Square Error)
Exponential Smoothing
Adjusted exponential smoothing
Linear regression models
A typical problem involving forecasting is the following: ACME MP3 Inc. manufactures mp3 players.
Following are MP3 player sales for the last 15 months in thousands of dollars. The company is planning
for month 16. The company will need to borrow $10 for each unit produced from a bank that charges an
interest rate of 2%. How much money should the company borrows?
Month 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Sales [000] 60 56 64 55 65 68 65 67 71 65 68 77 72 70 64
Before solving the problem the first step is to plot the data. Data Plots are important since it allow
visualizing trends and outliers (i.e., weird values)
Sales [000]
90
80
70
60
50
40
30
20
10
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Month
Notice that the amount of money needed by the company is a function of the next month prediction.
Additionally, if the company does not borrow enough, customers will be lost. If the company borrows
too much, interest will be paid for unused money.
A data set such the one showed in the last table is called a time series. A time series is a set of values
that are order based on time of occurrency. Let’s solve the problem using some of the methods
mentioned before.
1. Naïve method
The first step for solving our problem is to predict or forecast the sales for month 16. The naïve method
is the simplest method. Naïve forecasts are obtained using the following formula:
Ft +1= A t
Where t+1 is the forecasted period, Ft+1 represent forecast figure and At represents the demand of the
previous period. In other words, a naïve forecast is the sales of the previous period.
F16 =A 15=64
That is the naïve method states that the sales for month 16 are the same as the sales of the current
period. Consequently, the company needs to borrow $640,000 for the next month. The company will
pay $640,000*0.02=$12,800 in interests.
2. Moving average
Moving average methods are among the most popular methods in forecasting. Following is the formula
for the moving average:
∑ xi
k
Ft +1 =
k
Where k is the number of periods selected by the user. That is, the forecast is the average of the last k
observations. Let’s calculate some moving average forecasting figures:
A14 + A 15 70+ 64
F16 = = =67
MA2 k = 2 2 2 Borrow $670,000 ($13,400 of interest)
At this point we have four different forecast figures for month 16. Now, the question is which one is the
best one? Or in technical words, which is the more accurate forecast? It is impossible to know until the
end of month 16. At that point it is possible to compare the forecast figure against real sales. Using the
same reasoning, it is possible to apply the forecasting methods to previous data and see how accurate
the method is. That is done by comparing forecast figures against real sales. Let’s apply the naïve
method to our data. Recall that the naïve method uses the previous demand as forecast. That is, F2 = A1 =
60 and so on. Once we have the forecast for each month, we can calculate the differences between
forecast figures and real sales (At – Ft). See table below for the results:
Month 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Sales [000] 60 56 64 55 65 68 65 67 71 65 68 77 72 70 64
Naïve Ft 60 56 64 55 65 68 65 67 71 65 68 77 72 70 64
Difference -4 8 -9 10 3 -3 2 4 -6 3 9 -5 2 6
Notice that some values are negative and others are positive. It means that sometimes the naïve
method guess is lower than the real sales and other times the method guess is greater than real sales. It
means that sometimes the company won’t borrow enough money, and other times the company
borrowed a little bit more than needed. The differences are used to estimate the accuracy of the
method. Among other methods is the so called Mean Square Error (MSE). The MSE formula is as follows:
∑ ( A t −F t )2
MSE=
N
Notice that the MSE is the same as the population variance covered in statistics. Another advantage of
the MSE is that it allows the construction of confidence intervals. The following table illustrates the
process of calculating the MSE for the naïve method:
Month At Ft diff^2
1 60
2 56 60 16
3 64 56 64
4 55 64 81
5 65 55 100
6 68 65 9
7 65 68 9
8 67 65 4
9 71 67 16
10 65 71 36
11 68 65 9
12 77 68 81
13 72 77 25
14 70 72 4
15 64 70 36
16 64
Total 490
∑ ( A t −F t )2 490
MSE= =
N 14
N is the number of differences that are calculated, in this case there are 14 differences.
The next table includes MSE calculations for the Naïve method, MA2, MA3 and MA4.
Notice that the first forecast period for moving average methods is defined by the value of k. for
example the first forecast for MA4 is period 5 since the method needs k=4 periods to calculate the
value.
∑ ( A t −F t )2 490
MSE= = =35
N 14
Naïve
2
∑ ( A t −F t ) 378 . 5
MSE= = =29. 11
N 13
MA2
2
MSE=
∑ ( A t −F t ) 317 . 8
= =26 . 48
N 12
MA3
2
MSE=
∑ ( A t −F t ) 301 . 2
= =27 . 38
N 11
MA4
The MSE measures the accuracy of forecasting methods according to the history. Notice that MA3 has
the lowest MSE, therefore it is the most accurate method. In other words, among the 4 forecast figures
the best one is to plan using a forecast figure of 68.7 thousand units.
Important: There is no best forecasting method. Since each company is different, some methods work
better than others for different data sets. In real life, different methods are used and the one with the
lowest MSE is selected.
ES is probably the most used method in forecasting. The formula used to make calculations in ES is as
follows:
Ft +1 =αA t +(1−α )F t
Where: α (alpha) is the smoothing constant: 0 ≤ α ≤ 1. In real life the value of is obtained by trial and
error. For the moment let’s work with α = 0.2.
Notice that we need to know the forecasting figure for the previous month (i.e., month 15) in order to
calculate F16. Therefore, ES uses all the information available. That is, the method starts by assigning A1
to period 2. (i.e., F2 = A1). Once, F2 is known, it is possible to calculate F3 as follows:
The process is repeated for each month until month 16. The following table is a summary of ES
calculations:
Notice that it is necessary to forecast each month in order to obtain the forecast for month 16.
Therefore, the company needs to borrow $679,000 for the next month according to ES with α =0.2.
In real life, the process is repeated with different values for and the one that provides the lowest MSE
is selected. Next table shows the results of ES with different values for α.
Notice that the lowest MSE is obtained by using ES with α =0.4. ES calculations are easy to do in excel. In
real life, the best value of α is found by trial and error.
Finally, lower values of α generate higher levels of smoothing. The chart in the next page shows At and
ES with α =0.4 and α =0.8. Notice than the line for α =0.4 is smother (i.e., has less peaks) than the one
for α =0.8. In fact an α value of 1 is the naïve method.
80
75
70
At
65
Alpha = 0.4
Alpha = 0.8
60
55
50
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Naïve, MA, and ES do not work well with trends. That is, when At increases or decreases over time.
Adjusted exponential smoothing (AES), also called double exponential smoothing, is an improvement
over ES to deal with trends.
AES t+1=F t+1 +T t+1
Ft +1 =αA t +(1−α )F t
T t +1=β ( F t+1−F t )+(1−β )T t
The first term in the AESt+1 is the same ES explained before, see second equation. The second term Tt+1 is
called trend. Notice that the trend uses the results from ES and has another constant represented by the
Greek letter beta (β). β ranges between 0 and 1 (i.e., 0 ≤ β ≤ 1), its value is selected by the user. The
process will be explained using an example.
ACME MP3 Inc. also assembly dvd players. Following is the sales in 1000 of units in the last 15 months.
For every 1000 units sold the company needs an additional employee. The head of human resources
need to know how many workers will be needed by the cd players division to plan future hiring.
90
80
70
60
50
40
30
20
10
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Mont
h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Sales 52 59 65 50 54 65 70 76 61 80 85 69 73 78 80 ??
The first step is to calculate ES as before. Second is to calculate the trend term. The trend for the second
period is always 0. Trend calculations starts at the third period. Once all the trends are obtained, AESt is
obtained by adding trend values to ES values. Once AESt values are obtained, MSE is calculated. Notice
that MSE values are not calculated for the trend. The next table summarizes the calculations for AESt
with α = 0.4 and β = 0.1.
Linear regression works well when the data shows increasing or decreasing trends. Linear and other
types of equations are easily obtained using excel.
The first step is to plot the data using excel (just select the data and insert a linear chart. Once the chart
appears, locate the mouse pointer over the demand line. Then, right click on the mouse and select add
trend line. On the trend line screen select linear and check the display equation and display R-squared
value. Finally close the menu. Te final result is shown in the next graph.
90
80
f(x) = 1.93 x + 52.37
R² = 0.61
70
60
50
40
30
20
10
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The R2 tell how good is the regression to make predictions. An R2 greater then 0.9o means that the
model is very good. An R2 lower than 0.70 means that the linear regression is weak and should be used
with caution. An R2 lower that 0.40 means that the regression model is bad.
The x value in the regression model represent months. For example, the prediction for month 16 is
obtained as follows:
y=1.9286x+52.371
y=1.9286∗16+52.371=83.2
Month Sales Calculations Forecast
(Ft-At)2
(i) (At) (Ft)
1 60 1.9286*1+52.371 54.3 5.3
2 56 1.9286*2+52.371 56.2 7.7
3 64 1.9286*3+52.371 58.2 46.8
4 55 1.9286*4+52.371 60.1 101.7
5 65 1.9286*5+52.371 62.0 64.2
6 68 1.9286*6+52.371 63.9 1.1
7 65 1.9286*7+52.371 65.9 17.0
8 67 1.9286*8+52.371 67.8 67.2
9 71 1.9286*9+52.371 69.7 76.2
10 65 1.9286*10+52.371 71.7 69.6
11 78 1.9286*11+52.371 73.6 130.3
12 77 1.9286*12+52.371 75.5 42.4
13 72 1.9286*13+52.371 77.4 19.7
14 70 1.9286*14+52.371 79.4 1.9
15 64 1.9286*15+52.371 81.3 1.7
16 1.9286*16+52.371 83.2 5.3
The MSE for the linear regression forecast is:
∑ ( A t −F t )2 653 . 0
MSE= = =43 . 53
N 15
Notice that the linear regression model provides a better forecasting than Adjusted Exponential
Smoothing.
Final comments
The forecasting methods presented in this tutorial are based on the past. In real life forecasting figures
are reviewed by experts. These experts incorporate other factors in the forecasting such as current
economic conditions, market trends, etc.