You are on page 1of 39

Introduction to

(Demand) Forecasting

Topics
Introduction to (demand) forecasting
Overview of forecasting methods
A generic approach to quantitative forecasting
Time series-based forecasting
Building causal models through multiple linear
regression
Confidence Intervals and their application in forecasting
Forecasting
The process of predicting the values of a certain quantity,
Q, over a certain time horizon, T, based on past trends
and/or a number of relevant factors.
Some forecasted quantities in manufacturing
demand
equipment and employee availability
technological forecasts
economic forecasts (e.g., inflation rates, exchange rates, housing
starts, etc.)
The time horizon depends on
the nature of the forecasted quantity
the intended use of the forecast


Forecasting future demand
Demand forecasting is based on:
extrapolating to the future past trends observed in the company
sales;
understanding the impact of various factors on the company future
sales:
market data
strategic plans of the company
technology trends
social/economic/political factors
environmental factors
etc

Remark: The longer the forecasting horizon, the more
crucial the impact of the factors listed above.

Demand Patterns
The observed demand is the cumulative result of:
systematic variation, due to a number of identified factors, and
a random component, incorporating all the remaining unaccounted
effects.
Patterns of systematic variation
seasonal: cyclical patterns related to the calendar (e.g., holidays,
weather)
cyclical: patterns related to changes of the market size, due to, e.g.,
economics and politics
business: patterns related to changes in the company market share,
due to e.g., marketing activity and competition
product life cycle: patterns reflecting changes to the product life

The problem of demand forecasting
Identify and characterize the systematic
variation, as a set of trends.

Characterize the variability in the demand.

Forecasting Methods
Qualitative (Subjective): Incorporate factors like
the forecasters intuition, emotions, personal
experience, and value system.
These methods include:
Jury of executive opinion
Sales force composites
Delphi method
Consumer market surveys

Forecasting Methods (cont.)
Quantitative (Objective): Employ one or more
mathematical models that rely on historical data
and/or causal/indicator variables to forecast
demand.
Major methods include:
time series methods: F(t+1) = f (D(t), D(t-1), )
causal models: F(t+1) = f(X1(t), X2(t), )


Selecting a Forecasting Method
It should be based on the following considerations:
Forecasting horizon (validity of extrapolating past data)
Availability and quality of data
Lead Times (time pressures)
Cost of forecasting (understanding the value of
forecasting accuracy)
Forecasting flexibility (amenability of the model to
revision; quite often, a trade-off between filtering out
noise and the ability of the model to respond to abrupt
and/or drastic changes)

Implementing Quantitative Forecasting
Determine Method
Time Series
Causal Model
Collect data:
<Ind.Vars; Obs. Dem.>
Fit an analytical model
to the data:
F(t+1) = f(X1, X2,)
Use the model for
forecasting future
demand
Monitor error:
e(t+1) = D(t+1)-F(t+1)
Model
Valid?
Update Model
Parameters
Yes No
- Determine
functional form
- Estimate parameters
- Validate
Time Series-based Forecasting
Basic Model:
Historical
Data
,... 2 , 1 ), (

= + t t t D t i i D ,..., 1 ), ( =
Forecasts
Time Series
Model
Remark: The exact model to be used depends on the expected /
observed trends in the data.
Cases typically considered:
Constant mean series
Series with linear trend
Series with seasonalities (and possibly a linear trend)
A constant mean series
0.00
2.00
4.00
6.00
8.00
10.00
12.00
14.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Series1
The above data points have been sampled from a normal distribution with a
mean value equal to 10.0 and a variance equal to 4.0.
Forecasting constant mean series:
The Moving Average model
The presumed model for the observed data:
) ( ) ( t e D t D + =
where
D
is the constant mean of the series and
) (t e is normally distributed with zero mean and some unknown
variance
2
o
Then, under a Moving Average of Order N model, denoted as MA(N),
the estimate of returned at period t, is equal to:
D

=
=
1
0
) (
1
) (

N
i
i t D
N
t D
The forecasting error
The forecasting error


Also

=
+ = + = +
1
0
) 1 ( ) (
1
) 1 ( ) (

) 1 (
N
i
t D i t D
N
t D t D t c

=
= = + = +
1
0
0 ) (
1
)] 1 ( [ )] ( [
1
)] 1 ( [
N
i
D D N
N
t D E i t D E
N
t E c

=
+ = + = + + = +
1
0
2 2 2
2 2
)
1
1 (
1
)] 1 ( [ )] ( [
1
)] 1 ( [
N
i
N
N
N
t D Var i t D Var
N
t Var o o o c
Forecasting error (cont.)
c(t+1) is normally distributed with the mean and
variance computed in the previous slide.

follows a normal distribution with zero
mean and variance o
2
/N.

D t D ) (

Selecting an appropriate order N


Smaller values of N provide more flexibility.
Larger values of N provide more accuracy (c.f., the formula for the
variance of the forecasting error).
Hence, the more stable (stationary) the process, the larger the N.
In practice, N is selected through trial and error, such that it
minimizes one of the following criteria:
i)

ii)

iii)

+ =

=
t
N i
t
N t
t MAD
1
| ) ( |
1
) ( c

+ =

=
t
N i
t
N t
t MSD
1
2
)) ( (
1
) ( c

+ =

=
t
N i
t D
t
N t
t MAPE
1
) (
) ( 1
) (
c
Demonstrating the impact of N on
the model performance
0.00
5.00
10.00
15.00
20.00
25.00
1 4 7
1
0
1
3
1
6
1
9
2
2
2
5
2
8
3
1
3
4
3
7
4
0
Series1
Series2
Series3
blue series: the original data series, distributed according to N(10,4) for the first 20
points, and N(20,4) for the last 20 points.
magenta series: the predictions of the MA(5) forecasting model.
yellow series: the predictions of the MA(10) forecasting model.
Remark: the MA(5) model adjusts faster to the experienced jump of the data mean
value, but the mean estimates that it provides under stationary operation are less accurate
than those provided by the MA(10) model.
Forecasting constant mean series:
The Simple Exponential Smoothing model
The presumed demand model:
) ( ) ( t e D t D + =
where is an unknown constant and is normally distributed
with zero mean and an unknown variance .
D ) (t e
2
o
The forecast , at the end of period t: ) (

t D
)] 1 (

) ( [ ) 1 (

) 1 (

) 1 ( ) ( ) (

+ = + = t D t D a t D t D a t aD t D
where oe(0,1) is known as the smoothing constant.
Remark: The updating equation constitutes a correction of the
previous estimate in the direction suggested by the forecasting error,
) 1 (

) ( t D t D
Expanding the Model Recursion
) 1 (

) 1 ( ) ( ) (

+ = t D a t aD t D

= aD(t) + a(1 a)D(t 1) + (1 a)
2
D (t 2) =
.................................................................................................

=
+ =
1
0
) 0 (

) 1 ( ) ( ) 1 (
t
i
t i
D a i t D a a
Implications
1. The model considers all the past observations and the
initializing value in the determination of the
estimate .
2. The weight of the various data points decreases
exponentially with their age.
3. As o1, the model places more emphasis on the most
recent observations.
4. As t,


) (

t D
) 0 (

D
D t D E )] (

[ and
2
2
2
)] (

) 1 ( [ o
a
t D t D Var

+
The impact of o and of on
the model performance
0.00
5.00
10.00
15.00
20.00
25.00
1 4 7
1
0
1
3
1
6
1
9
2
2
2
5
2
8
3
1
3
4
3
7
4
0
Series1
Series2
Series3
Series4
) 0 (

D
dark blue series: the original data series, distributed according to N(10,4) for the first 20
points, and N(20,4) for the last 20 points.
magenta series: the predictions of the ES(0.2) model initialized at the value of 10.0.
yellow series: the predictions of the ES(0.2) model initialized as 0.0.
light blue series: the predictions of the ES(0.8) model initialized at 10.0.
Remark: the ES(0.8) model adjusts faster to the jump of the series mean value, but the
estimates that it provides under stationary operation are less accurate than those provided by
the ES(0.2) model. Also, notice that the effect of the initial value is only transient.
The inadequacy of SES and MA
models for data with linear trends
0
2
4
6
8
10
12
1 2 3 4 5 6 7 8 9 10
Dt
SES(0.5)
SES(1.0)
blue series: a deterministic data series increasing linearly with a slope of 1.0.
magenta series: the predictions obtained from the SES(0.5) model initialized at
the exact value of 1.0.
yellow series: the predictions obtained from the SES(1.0) model initialized at
the exact value of 1.0.
Remark: Both models under-estimate the actual values, with the most inert
model SES(0.5) under-estimating the most. This should be expected since both of
these models (as well as any MA model) essentially average the past
observations. Therefore, neither the MA nor the SES model are appropriate for
forecasting a data series with a linear trend in it.
Forecasting series with linear trend:
The Double Exponential Smoothing Model
The presumed data model:
) ( ) ( t e t T I t D + + =
where
I is the model intercept, i.e., the unknown mean value for t=0,
) (t e
is normally distributed with zero mean and some unknown
variance
2
o
T is the model trend, i.e., the mean increase per unit of time, and

The Double Exponential Smoothing
Model (cont.)
The parameters a and | take values in the interval (0,1) and are the
model smoothing constants, while the values and are the
initializing values.
The model forecasts at period t for periods t+t, t=1,2,, are
given by:
t t + = + ) (

) (

) (

t T t I t D
with the quantities and obtained through the following
recursions:
) (

t I
) (

t T
)] 1 (

) 1 (

)[ 1 ( ) ( ) (

+ + = t T t I a t D a t I
) 1 (

) 1 ( )] 1 (

) (

[ ) (

+ = t T t I t I t T | |
) 0 (

I
) 0 (

T
The Double Exponential Smoothing
Model (cont.)
The smoothing constants are chosen by trial and error, using the
MAD, MSD and/or MAPE indices.
For t, and
The variance of the forecasting error, , can be estimated as a
function of the noise variance o
2
through techniques similar to
those used in the case of the Simple Exp. Smoothing model, but in
practice, it is frequently approximated by

where

for some appropriately selected smoothing constant e(0,1) or by

I t I ) (

T t T ) (

2
c
o
) ( 25 . 1
2
t MAD =
c
o
) 1 ( ) 1 ( ) ( ) ( + = t MAD t t MAD c
) (
2
t MSD =
c
o
DES Example
0
2
4
6
8
10
12
1 2 3 4 5 6 7 8 9 10
Dt
DES(T0=1)
DES(T0=0)
blue series: a deterministic data series increasing linearly with a slope of 1.0.
magenta series: the predictions obtained from the DES(0.5;0.2) model initialized
at the exact value of 1.0.
yellow series: the predictions obtained from the DES(0.5;0.2) model initialized
at the value of 0.0.
Remark: In the absence of variability in the original data, the first model is
completely accurate (the blue and the magenta series overlap completely), while
the second model overcomes the deficiency of the wrong initial estimate and
eventually converges to the correct values.
Time Series-based Forecasting:
Accommodating seasonal behavior
The data demonstrate a periodic behavior (and maybe some
additional linear trend).

Example: Consider the following data, describing a quarterly
demand over the last 3 years, in 1000s:
Year 1 Year 2 Year 3
Spring 90 115 120
Summer 180 230 290
Fall 70 85 105
Winter 60 70 100
Total 400 500 615
Seasonal Indices
0
50
100
150
200
250
300
350
0 2 4 6 8 10 12 14
Series1
Plotting the demand data:
Remarks:
At each cycle, the demand of a particular season is a fairly stable percentage of
the total demand over the cycle.
Hence, the ratio of a seasonal demand to the average seasonal demand of the
corresponding cycle will be fairly constant.
This ratio is characterized as the corresponding seasonal index.
A forecasting methodology
Forecasts for the seasonal demand for subsequent years can be obtained by:
i. estimating the seasonal indices corresponding to the various seasons in the
cycle;
ii. estimating the average seasonal demand for the considered cycle (using, for
instance, a forecasting model for a series with constant mean or linear trend,
depending on the situation);
iii. adjusting the average seasonal demand by multiplying it with the
corresponding seasonal index.
Example (cont.):
Year 1 Year 2 Year 3 SI(1) SI(2) SI(3) SI
Spring 90 115 120 0.9 0.92 0.78 0.87
Summer 180 230 290 1.8 1.84 1.88 1.84
Fall 70 85 105 0.7 0.68 0.68 0.69
Winter 60 70 100 0.6 0.56 0.65 0.6
Total 400 500 615 4 4 4 4
Average 100 125 153.75
Winters Method for Seasonal
Forecasting
The presumed model for the observed data:
) ( ) ( ) (
1 mod ) 1 (
t e c t T I t D
N t
+ + =
+
where

N denotes the number of seasons in a cycle;

c
i
, i=1,2,N, is the seasonal index for the i-th season in the cycle;

I is the intercept for the de-seasonalized series obtained by dividing the
original demand series with the corresponding seasonal indices;

T is the trend of the de-seasonalized series;

e(t) is normally distributed with zero mean and some unknown variance
2
o
Winters Method for Seasonal Forecasting
(cont.)
The model forecasts at period t for periods t+t, t=1,2,, are given by:
) (

] ) (

) (

[ ) (

1 mod ) 1 (
t c t T t I t D
N t + +
+ = +
t
t t
where the quantities , and are obtained from the
following recursions, performed in the indicated sequence:
) (

t I
) (

t T
, ,..., 1 ), ( N i t c
i
=
)] 1 (

) 1 (

)[ 1 (
) 1 (
) (
: ) (

1 mod ) 1 (
+ +

=
+
t T t I a
t c
t D
a t I
N t
) 1 (

) 1 ( )] 1 (

) (

[ : ) (

+ = t T t I t I t T | |
) 1 ( ) 1 (
) (

) (
: ) (
1 mod ) 1 ( 1 mod ) 1 (
+ =
+ +
t c
t I
t D
t c
N t N t

1 mod ) 1 ( ), 1 ( : ) ( + = = N t i t c t c
i i
The parameters o, |, take values in the interval (0,1) and are the model smoothing
constants, while and are the initializing values.


I (0),

T (0)
, ,..., 1 ), 0 ( N i c
i
=
Causal Models:
Multiple Linear Regression
The basic model:
e X b X b b D
k k
+ + + + = ...
1 1 0
where
X
i
, i=1,,k, are the model independent variables (otherwise known as the
explanatory variables);
b
i
, i=0,,k, are unknown model parameters;
e is the a random variable following a normal distribution with zero mean and
some unknown variance o
2
.
D follows a normal distribution where
) , (
2
o D N
k k
X b X b b D + + + = ...
1 1 0
We need to estimate <b
0
,b
1
,,b
k
> and o
2
from a set of n observations
} ,..., 1 , ,..., , ; {
2 1
n j X X X D
kj j j j
= > <
Estimating the parameters b
i

The observed data satisfy the following equation:
(
(
(
(

+
(
(
(
(

(
(
(
(

=
(
(
(
(

n k kn n
k
k
n
e
e
e
b
b
b
X X
X X
X X
D
D
D
... ...
... 1
... ... ... ...
... 1
... 1
...
2
1
1
0
1
2 12
1 11
2
1
or in a more concise form
e b X d + =
The vector
b X d e =
denotes the difference between the actual observations and the corresponding
mean values, and therefore, is selected such that it minimizes the Euclidean
norm of the resulting vector .
b

b X d e

=
The minimizing value for is equal to
d X X X b
T T 1
) (


=
The necessary and sufficient condition for the existence of is that the
columns of matrix X are linearly independent.
1
) (

X X
T
b

Characterizing the model variance


An unbiased estimate of o
2
is given by
1
=
k n
SSE
MSE
where
(Mean Squared Error)
)

( )

( b X d b X d e e SSE
T T
= =
(Sum of Squared Errors)
The quantity SSE/o
2
follows a Chi-square distribution with n-k-1 degrees of
freedom.
Given a point x
0
T
=(1,x
10
,,x
k0
), an unbiased estimator of is given by
) (
0
x D
0 10 1 0 0

...

) (

k k
x b x b b x D + + + =
This estimator is normally distributed with mean and variance
) (
0
x D
0
1
0
2
) ( x X X x
T
T

o
The random variable can function also as an estimator for any single
observation D(x
0
). The resulting error will have zero mean and
variance
) (

0
x D
) ( ) (

0 0
x D x D
] ) ( 1 [
0
1
0
2
x X X x
T
T

+ o
Assessing the goodness of fit
A rigorous characterization of the quality of the resulting approximation can be
obtained through Analysis of Variance, that can be traced in any introductory book
on statistics.

A more empirical test considers the coefficient of multiple determination
YY
S
SSR
R =
2
where


=
= =
n
j
j
T T
d D d n d X b SSR
1
2 2
)

( ) (

=
=
n
j
j
D
n
d
1
1
and
SSR SSE S
YY
+ =
Remark: A natural way to interpret R
2
is as the fraction of the variability in the
observed data interpreted by the model over the total variability in this data.
Multiple Linear Regression and
Time Series-based forecasting
The model needs to be linear with respect to the parameters b
i
but not the
explanatory variables X
i
. Hence, the factor multiplying the parameter b
i
can be any
function f
i
of the underlying explanatory variables.

When the only explanatory variable is just the time variable t, the resulting multiple
linear regression model essentially supports time-series analysis.

The above approach for time-series analysis enables the study of more complex
dependencies on time than those addressed by the moving average and exponential
smoothing models.

The integration of a new observation in multiple linear regression models is much
more cumbersome than the updating performed by the moving average and
exponential smoothing models (although there is an incremental linear regression
model that alleviates this problem).

Confidence Intervals
Confidence intervals are used in:
i. monitoring the performance of the applied forecasting model;
ii. adjusting an obtained forecast in order to achieve a certain
performance level
Given a random variable X and pe(0,1), a p100 confidence
interval (CI) for it is an interval [a,b] such that
p b X a P = s s ) (
The necessary confidence intervals are obtained by exploiting
the statistics for the forecasting error, derived in the previous
slides.
Variance estimation and the t distribution
The variance of the forecasting error is a function of the unknown variance,
o
2
, of the model disturbance, e.
E.g., in the case of multiple linear regression, the variance of the forecasting
error is equal to .
) ( ) (

0 0
x D x D ] ) ( 1 [
0
1
0
2
x X X x
T
T

+ o
Hence, one cannot take advantage directly of the normality of the forecasting
error in order to build the sought confidence intervals.
This problem can be circumvented by exploiting the fact that the quantity
SSE/o
2
follows a Chi-square distribution with n-k-1 degrees of freedom.
Then, the quantity
] ) ( 1 [
) ( ) (

1
) ( 1 )] ( ) (

[
0
1
0
0 0
2
0
1
0 0 0
x X X x MSE
x D x D
k n
SSE
x X X x x D x D
T
T
T
T
T

+

=

+
=
o
o
follows a t distribution with n-k-1 degrees of freedom.
For large samples, T can also be approximated by a standardized normal
distribution.
Adjusting the forecasted demand in
order to achieve a target service level p
Letting y denote the required adjustment, we essentially need to solve the following
equation:
= + s p y x D x D P ) ) (

) ( (
0 0
=
+
s
+


p
x X X x MSE
y
x X X x MSE
x D x D
P
T
T
T
T
)
] ) ( 1 [ ] ) ( 1 [
) (

) (
(
0
1
0 0
1
0
0 0
=
+

1 ,
0
1
0
] ) ( 1 [
k n p
T
T
t
x X X x MSE
y
] ) ( 1 [
0
1
0 1 ,
x X X x MSE t y
T
T
k n p


+ =
Remark: The two-sided confidence interval that is necessary for monitoring the
model performance can be obtained through a straightforward modification of the
above reasoning.

You might also like