You are on page 1of 55

8/11/2022

Chapter 6
Time Series and Forecasting

Objectives
After completing this chapter, you can:
• Describe the trend, cyclical, seasonal, and irregular components of the
time series model.
• Smooth a time series with the moving average and exponential smoothing
techniques.
• Fit a linear or nonlinear trend equation to a time series.
• Determine seasonal indexes and use them to compensate for the
seasonal effects in a time series.
• Use the forecast methods to estimate a future value.
• Use forecast accuracy to compare how well equations fit data.

1
8/11/2022

Outline
• Time series & its components
• Smoothing methods
• Finding the trend
• Finding Seasonal variation
• Forecasting

What is Time Series?


• A time series is a sequence of numerical data taken every hour, day,
week, month, quarter, year, or at any other regular time interval.
• Occurs in many areas: economics, finance, environment, medicine…
• E.g. Number of babies born in each hour
• Daily closing price of a stock
• The monthly trade balance of Vietnam for each year
• GDP of the country, measured each year

2
8/11/2022

Why are time series data different


from other data?
• Data are not independent
• Much of the statistical theory relies on the data being independent and
identically distributed
• Large samples sizes are good, but long time series are not always the best
• Series often change with time, so bigger isn’t always better

Time series analysis


• The main objective of time series analysis is to forecast. The more we
understand a time series and its components, the more accurate the
prediction is.
• Assuming that factors influencing the past, present, & future will
continue
• Need to reduce and eliminate random variation and understand
how other components in a time series are combined  better
forecast

3
8/11/2022

Time Series Plot


• A useful first step in selecting an appropriate forecasting method is to
construct a time series plot.
• A time series plot is a graphical presentation of the relationship between
time and the time series variable.
• Time is on the horizontal axis, and the time series values are shown on the
vertical axis.

Time Series Plot

 the vertical axis


measures the variable
of interest
 the horizontal axis
corresponds to the
time periods

Connecting sequential data points by lines helps


emphasize any change over time.
8

4
8/11/2022

Classical Decomposition
• One method of describing a time series
• Decompose the series into various components: Trend, Seasonal effects,
Cycles and Irregular
• Our aim is to understand and identify different variations so that we can
easily predict the future variations separately and combine together
• Look how the above complicated series could be understood as follows
separately

Time Series Components

Time
Series

Trend Seasonality Cyclical Irregular


Component Component Component Component

10

5
8/11/2022

Trend Component
• Trend: the long-term patterns or movements in the data.
• Overall or persistent, long-term upward or downward pattern of movement.
• Due to long-term factors such as changes in the population,
demographics, technology, or consumer preferences

Sales

Time

11

Trend Component
• Trend can be upward or downward
• Trend can be linear or non-linear

Sales Sales

Time Time
Downward linear trend Upward nonlinear trend

12

6
8/11/2022

Seasonal Component
• Short-term regular wave-like patterns
• Observed within 1 year
• Often monthly or quarterly
• Due to weather, customs, seasons in the year or particular patterns during
a month, a week, or a day
• E.g. Consumption of heating oil, which is high in winter, and low in
other seasons of year.
• Gasoline consumption, which is high in summer when most people go
on vacation.

13

Seasonal Component

Year n+1

Sales Year n

Summer
Winter
Summer
Winter Spring Fall

Spring Fall

Time (Quarterly)

14

7
8/11/2022

Cyclical Component
• Long-term wave-like patterns
• Regularly occur but may vary in length
• Often measured peak to peak or trough to trough
• Due to interaction of factors influencing economy
• E.g. Business cycle of some 8 to 10 years between period of “Boom”
and “Bust” in modern industrialised economies
• Financial crisis or economic crisis is around 20 to 30 years

15

Cyclical Component

1 Cycle
Sales

Year

16

8
8/11/2022

Irregular Component
• Unpredictable, random, “residual” fluctuations
• Due to random variations of:
• Nature (earthquake, tsunami…)
• Accidents or unusual events (union strike…)
• Short duration & nonrepeating
• Makes it difficult to detect the pattern of other components in a time series
(“noise” in the time series)
→ One of the tasks in time series analysis is to eliminate random variation
out of a time series

17

Time-Series Component Analysis


• The four components of a time series can be modeled by adding or
multiplying the respective components

• Additive model: appropriate in situations


where the seasonal fluctuations do not 𝐘𝐭 𝐓𝐭 𝐒𝐭 𝐂𝐭 𝐈𝐭
depend upon the level of the time series.

where Yt denotes the actual data of a time series


Tt = Trend value at time period t
St = Seasonality value at time period
Ct = Cyclical value at time t
It = Irregular (random) value at time period t

18

9
8/11/2022

Time-Series Component Analysis


• The four components of a time series can be modeled by adding or
multiplying the respective components
• Multiplicative model: appropriate, for
example, if the seasonal fluctuations grow 𝐘𝐭 𝐓𝐭 𝐱 𝐒𝐭 𝐱 𝐂𝐭 𝐱 𝐈𝐭
larger as the sales volume increases
because of a long-term linear trend.

where Yt denotes the actual data of a time series


Tt = Trend value at time period t
St = Seasonality value at time period
Ct = Cyclical value at time t
It = Irregular (random) value at time period t

19

Time-Series Component Analysis

Y Y

t t

Additive model Multiplicative model

20

10
8/11/2022

Time series patterns


• The pattern of the data is an important factor in understanding how the
time series has behaved in the past
• If such behavior can be expected to continue in the future, we can use it to
guide us in selecting an appropriate forecasting method.

21

Time series patterns


• The common types of data patterns that can be identified when examining
a time series plot include:
• Horizontal
• Trend
• Seasonal
• Trend and Seasonal: In such cases we need to use a forecasting
method that has the capability to deal with both trend and seasonality.
• Cyclical: In this chapter we do not deal with cyclical effects because of
unavailable data

22

11
8/11/2022

Time series patterns


• Horizontal: exists when the data fluctuate around a constant
mean. 25

20

Sales ($ Millions)
15

10

0
0 2 4 6 8 10 12 14
Week

23

Smoothing methods
• Smoothing methods dampen the impacts of fluctuation in a time series,
thereby providing a better view of the trend and (possibly) the cyclical
components. Used with Horizontal pattern, include:
• Moving Averages
• Exponential Smoothing
• They are called smoothing methods because their objective is to smooth
out the random fluctuations in the time series.
• They are most appropriate for short-range forecasts.

24

12
8/11/2022

Moving Averages
• Moving Averages (MA) is one of the smoothing methods
• Series of arithmetic means of the values of a fixed number of consecutive
time periods
• Used only for smoothing  provide overall impression of data over time
• Reduce/eliminate random variations or reveal the trend of a time series

25

Moving Averages
• We can choose any number of periods with which to calculate MA,
depending on our objectives
• Result depends upon choice of k (length of period for computing means)
• Examples:
• For a 3-year moving average, k = 3
• For a 5-year moving average, k = 5
• Etc.

26

13
8/11/2022

Moving Averages

• Odd number of points. Points (k) – length for computing MA


• Example: Five-year moving average
• First average:
x x x x x
MA
5

• Second average:
x x x x x
MA
5

• etc.

27

Moving Averages: Example


Year Sales
Annual Sales
1 23
2 40 60
3 25 50
4 27
40
5 32
Sales

30
6 48
7 33 20

8 37 10
9 37 0
10 50 1 2 3 4 5 6 7 8 9 10 11

11 40 Year

etc… etc…

28

14
8/11/2022

Moving Averages: Example


5-Year
Average Moving
Year Sales Year Average
1 23 3 29.4 23 40 25 27 32
2 40 𝑴𝑨𝟑 29.4
4 34.4 𝟓
3 25 5 33.0
4 27 6 35.4
5 32 7 37.4
6 48 8 41.0
7 33 9 39.4
8 37 etc… … …
9 37
10 50
11 40
• There are no values for MA1, MA2, MA10, MA11 in
this case.
29

Moving Averages: Example

Annual vs. 5-Year Moving Average

60
• The 5-year moving 50

average smoothes 40
Sales

30
the data and shows
20
the underlying
10
trend 0
1 2 3 4 5 6 7 8 9 10 11
Year

Annual 5-Year Moving Average

30

15
8/11/2022

Moving Averages
• Even number of points
• We need even numbered MA s for seasonal adjustments, e.g: 4 - quarterly
data; 12 - monthly data
• Two stages:
• Obtain MA, centered halfway between t and t-1.
• To get a trend take the average of two successive estimates. Estimate
centered halfway between t and t-1.

31

Moving Averages
• E.g. For k=4
Stage 1.
y y y y
MA .
4
y y y y
MA .
4

Stage 2. MA . MA .
MA
2

and so on.

32

16
8/11/2022

Moving Averages

4-Quarter Centered
• Average periods of 2.5 or 3.5
Average Moving Centered Moving don’t match the original
Period Average Period Average
periods, so we average two
2.5 28.75 3 29.88
consecutive moving
3.5 31.00 4 32.00
4.5 33.00
averages to get centered
5 34.00
5.5 35.00 6 36.25
moving averages
6.5 37.50 7 38.13
7.5 38.75 8 39.00
8.5 39.25 9 40.13
9.5 41.00

33

Moving averages: some notices


• The more periods involved in calculating MA, the smoother the series
becomes  the trend is detected more clearly, but it can hide the seasonal
component
• To reveal long-term trend/smoothing the time series  MA of large
number of periods
• As we place MA in the center of the group of values being averaged, it is
easy to choose the odd number of periods

34

17
8/11/2022

Exponential Smoothing
• This method provides an exponentially weighted moving average of all
previously observed values.
• Appropriate for data with no predictable upward or downward trend, no
seasonality
• The aim is to eliminate random variations and estimate the current level
and use it as a forecast of future value.

35

Exponential Smoothing
• Observed time series: Y1, Y2, …, Yn
• The equation for the model is

𝐒𝐭 𝛂𝐘𝐭 𝟏 𝟏 𝛂 𝐒𝐭 𝟏

where : the smoothing constant, 0    1


Yt: the value of the observation at time t
St: the value of the smoothed obs. at time t.

36

18
8/11/2022

Exponential Smoothing
• The equation can also be written as

𝐒𝐭 𝐒𝐭 𝟏 𝛂 𝒀𝐭 𝟏 𝑺𝐭 𝟏

Where: Y S is the forecast error


• Then, the forecast is

𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭 𝐒𝐭 𝛂 𝐘𝐭 𝐒𝐭

37

Exponential Smoothing: Notes


• The value of smoothing constant  must be between 0 and 1
•  can not be equal to 0 or 1.
• If stable predictions with smoothed random variation is desired then a
small value of  is desire.
• If a rapid response to a real change in the pattern of observations is
desired, a large value of  is appropriate

38

19
8/11/2022

Exponential Smoothing: Notes


• To estimate , Forecasts are computed for  equal to 0.1, 0.2, 0.3, …, 0.9
and the sum of squared forecast error is computed for each.
• The value of  with the smallest MSE is chosen for use in producing the
future forecasts.

In empirical works, 0.05    0.3 commonly used.

39

Exponential Smoothing: Example


Time Yt St ( = 0.1) (YtSt)2
1 5 𝑆 𝑌 -
2 7 𝑆 𝛼𝑌 1 𝛼 𝑆 (0.1) 5 + (0.9) 5 = 5 4
3 6 𝑆 𝛼𝑌 1 𝛼 𝑆 (0.1) 7 + (0.9) 5 = 5.2 0.64
4 3 𝑆 𝛼𝑌 1 𝛼 𝑆 (0.1) 6 + (0.9) 5.2 = 5.08 5.1984
5 4 𝑆 𝛼𝑌 1 𝛼 𝑆 (0.1) 3 + (0.9) 5.08 = 5.052 1.107
TOTAL 10.945

SSE 10.945
MSE 2.74
n 1 4

40

20
8/11/2022

Finding the trend


• A linear trend equation is used when the data are increasing (or
decreasing) by equal amounts
• If a time series exhibits a linear trend, the method of least squares
may be used to determine a trend line.
• A nonlinear trend equation is used when the data are increasing (or
decreasing) by increasing amounts over time

41

Linear trend regression


• Consider t as an independent variable in linear regression analysis, the
linear trend regression function is written as:

𝒀 𝜷𝟎 𝜷𝟏 𝒕 𝜺

• The estimated function:

𝒀 𝒃𝟎 𝒃𝟏 𝒕

where: 𝑌 = linear trend forecast in period t


b0 = intercept of the linear trend line
b1 = slope of the linear trend line
t = time period
42

21
8/11/2022

Linear trend regression


• Using the method of least squares

∑ 𝑡 𝑡̅ 𝑌 𝑌 ∑ 𝑡𝑌 ∑ 𝑡 ∑ 𝑌 /𝑛
𝑏 𝑏 𝑌 𝑏 𝑡̅
∑ 𝑡 𝑡̅ ∑𝑡 ∑ 𝑡 /𝑛

where: Yt = value of the time series in period t


𝑌= average values of the time series
n = number of time periods (observations)
𝑡̅ = average value of t

43

Linear trend regression


• E.g. The number of plumbing Month Jobs Month Jobs
repair jobs performed by
March 353 August 409
Auger's Plumbing Service in
the last nine months is listed Aprill 387 September 399

on the right. May 342 October 412

• Develop the linear trend June 374 November 408


regression function for this July 396
time series.

44

22
8/11/2022

Linear trend regression

Month Jobs (Y) t 𝒕 𝒕̅ 𝒕 𝒕̅ 𝟐 𝒀 𝒀 𝒕 𝒕̅ 𝒀 𝒀


March 353 1 -4 16 -33.67 134.67
Aprill 387 2 -3 9 0.33 -1.00
May 342 3 -2 4 -44.67 89.33
June 374 4 -1 1 -12.67 12.67
July 396 5 0 0 9.33 0.00
August 409 6 1 1 22.33 22.33
September 399 7 2 4 12.33 24.67
October 412 8 3 9 25.33 76.00
November 408 9 4 16 21.33 85.33
Total 3480 45 60 444
Average 𝒀 = 386.67 𝒕̅ = 5

45

Linear trend regression


• Calculate the slope and intercept of linear trend line

∑ 𝑡 𝑡̅ 𝑌 𝑌 444
𝑏 7.4
∑ 𝑡 𝑡̅ 60

𝑏 𝑌 𝑏 𝑡̅ 386.667 7.4 5 349.67

• The linear trend regression

𝑌 349.67 7.4𝑡

46

23
8/11/2022

Nonlinear Trend Regression


• Sometimes time series have a curvilinear or nonlinear trend.
• When data increase (or decrease) by equal percents or proportions plot
will show curvilinear pattern
• A variety of nonlinear functions can be used to develop an estimate of the
trend in a time series.

47

Nonlinear Trend Regression


• Quadratic trend equation

𝒀 = b0 + b1t + b2t 2

• Exponential trend equation

𝒀 = b0(b1)t or 𝒍𝒐𝒈𝒀 = logb0 + t logb1

• Inverse trend equation

𝒀 = b0 + b1(1/t)

48

24
8/11/2022

Nonlinear Trend Regression

• E.g. The annual revenue in Year Revenue Year Revenue


millions of dollars for a 1 23.1 6 43.2
cholesterol drug for the first 10
2 21.3 7 59.5
years of sales is shown below.
A curvilinear function appears 3 27.4 8 64.4
to be needed to model the 4 34.6 9 74.2
long-term trend. 5 33.8 10 99.3

49

Nonlinear Trend Regression

𝒀 = 24.182 -2.106t + 0.922t 2

50

25
8/11/2022

Finding Seasonal variation


• Assume no C in a time series model

• Additive model:

• Y=T+S+IY–T=S+I

• Multiplicative model:

• Y=TxSxIY/T=SxI

51

Steps in additive model


1. Get S + I = Y – T

2. Average S to remove I

3. Adjust S so that sum of S equal to zero  get the seasonal variation

52

26
8/11/2022

Additive model: Step 1


Actual Gasoline
Year Quarter Five-period MA (T) S+I=Y-T
sales (Y)
1 1 39
2 37
3 61 42.6 18.4
4 58 46.0 12.0
2 1 18 55.0 -37.0
2 56 48.2 7.8
3 82 44.8 37.2
4 27 55.0 -28.0
3 1 41 53.6 -12.6
2 69 50.4 18.6
3 49 55.8 -6.8
4 66 56.0 10.0
4 1 54 60.2 -6.2
2 42 63.6 -21.6
3 90
4 66

53

Additive model: Step 2


• The averaging process will remove I, leaving S only  take (S+I) from the
above table and rewritten as follows:

Year Q1 Q2 Q3 Q4
1 18.4 12.0
2 -37.0 7.8 37.2 -28.0
3 -12.6 18.6 -6.8 10.0
4 -6.2 -21.6
Total -55.8 4.8 48.8 -6.0
Average (S) -18.6 1.6 16.3 -2.0

54

27
8/11/2022

Additive model: Step 3


• The average value of S is unadjusted
• Variations around the trend should be cancelled out. In other words, Sum
of S must be equal to zero
• The adjusted S is the seasonal variation component. Sales are -17.92
below trend for Q1, +2.28 above trend for Q2, and so on

Q1 Q2 Q3 Q4 Total
Unadjusted S -18.60 1.60 16.27 -2.00 -2.73
Adjustment to reduce total
variation to zero 0.68 0.68 0.68 0.68 2.73
Adjustment S -17.92 2.28 16.95 -1.32 0.00

55

Steps in multiplicative model


1. For each type of season, compute the seasonal indexes: S x I = Y / T

2. Averaging seasonal indexes to remove I

3. Adjust the averages in step 2 so that the averages of all seasons is


equal to 1  adjusted S

56

28
8/11/2022

Multiplicative model: Step 1


Time period Actual Gasoline sales Trend Seasonal indexes
(t) (Y) (T) (Y/T)
1 39 41.0 0.951
2 37 42.7 0.867
3 61 44.3 1.376 Note:
4 58 46.0 1.261 Linear Trend Line
1 18 47.6 0.378
2 56 49.3 1.136 𝒀 𝟑𝟗. 𝟑𝟕𝟓 𝟏. 𝟔𝟓𝟒𝟒𝒕
3 82 51.0 1.609
4 27 52.6 0.513
1 41 54.3 0.756
2 69 55.9 1.234
3 49 57.6 0.851
4 66 59.2 1.114
1 54 60.9 0.887
2 42 62.5 0.672
3 90 64.2 1.402
4 66 65.8 1.002

57

Multiplicative model: Step 2


• Average S to remove I

Year Q1 Q2 Q3 Q4

1 0.951 0.867 1.376 1.261


2 0.378 1.136 1.609 0.513
3 0.756 1.234 0.851 1.114
4 0.887 0.672 1.402 1.002
Total 2.972 3.909 5.238 3.890
Average indexes (S) 0.743 0.977 1.309 0.973

58

29
8/11/2022

Multiplicative model: Step 3


• Adjust S so that the average of all S equal to 1
• The adjusted S shows that the sales of gasolines in the first quarter is
25.8% (100%-74.2%) below the trend

Q1 Q2 Q3 Q4 Total

Average indexes (S) 0.74300 0.97725 1.30950 0.97250 4.00225

Adjustment to reduce the sum


to 4 or the average of 1 -0.00056 -0.00056 -0.00056 -0.00056 -0.00225

Adjusted S 0.74244 0.97669 1.30894 0.97194

59

Deseasonalising a time series


• When we remove the seasonal component from a time series, the process
is called deseasonalising, and the result is called a seasonal adjusted
time series
• The objective of deseasonalising is to see the trend clearly
• Additive model: Seasonal adjusted time series = Actual values - Adjusted
seasonal variation
• Multiplicative model: Seasonal adjusted time series = Actual value /
Adjusted seasonal variation

60

30
8/11/2022

Deseasonalising a time series: Example


Adjusted Seasonal
Actual
Year Quarter seasonal adjusted time
sales (Y)
variation (S) series (Y-S)
2017 1 87.5 9.84 77.66
2 73.2 -6.21 79.41
3 64.8 -13.76 78.56
4 88.5 10.14 78.36
2018 1 90.3 9.84 80.46
2 76.0 -6.21 82.21
3 69.2 -13.76 82.96
4 94.7 10.14 84.56
2019 1 93.9 9.84 84.06
2 78.4 -6.21 84.61
3 72.0 -13.76 85.76
4 100.3 10.14 90.16

61

Activity
• The data values in the table below show quarterly sales of a corporation
over a period of six years.

Year Quarter 1 Quarter 2 Quarter 3 Quarter 4


1 272 239 158 219
2 228 198 169 238
3 270 246 203 284
4 299 267 218 293
5 307 258 323 296
6 307 271 197 266

62

31
8/11/2022

Activity
• Task 1: draw a time plot of this series, and discuss its features
• Task 2: compute the four-periods MA to find the trend and apply the
multiplicative model to calculate the seasonal component
• Task 3: compute the linear regression to find the trend and apply the
additive model to calculate the seasonal component

63

What is Forecasting?
• Process of predicting a future event
• Underlying basis of all business decisions
• Production
• Inventory
• Personnel
• Facilities
•…

64

32
8/11/2022

Forecasting Methods

Forecasting
Methods

Quantitative Qualitative

Causal Time Series

65

Forecasting Methods
• Qualitative Methods: generally involve the use of expert judgment to
develop forecasts.
• Such methods are appropriate when historical data on the variable
being forecast are either not applicable or unavailable.
• E.g. Forecasting on new products, new technology…

66

33
8/11/2022

Forecasting Methods
• Quantitative Methods: can be used when
• Past information about the variable being forecast is available,
• The information can be quantified, and
• It is reasonable to assume the pattern of the past will continue
• In such cases, a forecast can be developed using a time series method or
a causal method.
→ We will focus exclusively on quantitative forecasting methods in this
chapter.

67

Quantitative forecasting steps


 Select several forecasting methods
 “Forecast” the past
 Evaluate forecasts
 Select best method
 Forecast the future
 Monitor continuously forecast accuracy

68

34
8/11/2022

Quantitative Forecasting Methods


• Based on an analysis of historical data concerning one or more time
series.
• If the historical data used are restricted to past values of the series that we
are trying to forecast, the procedure is called a time series method.
• If the historical data used involve other time series that are believed to be
related to the time series that we are trying to forecast, the procedure is
called a causal method.

69

Quantitative Forecasting Methods


 Causal Methods
• Causal forecasting methods are based on the assumption that the variable
we are forecasting has a cause-effect relationship with one or more other
variables.
• Looking at regression analysis as a forecasting tool, we can view the time
series value that we want to forecast as the dependent variable.
• If we can identify a good set of related independent variables we may be
able to develop an estimated regression equation for forecasting the time
series.

70

35
8/11/2022

Quantitative Forecasting Methods


 Regression Analysis
• By treating time as the independent variable and the time series as a
dependent variable, regression analysis can also be used as a time series
method.
• Time-series regression refers to the use of regression analysis when
the sole independent variable is time.
• Cross-sectional regression refers to the use of regression analysis
when the independent variable(s) is (are) something other than time.

71

Quantitative Forecasting Methods


 Time series methods
• The objective of time series analysis is to discover a pattern in the
historical data or time series and then extrapolate the pattern into the
future.
• The forecast is based solely on past values of the variable and/or past
forecast errors.
→ We will focus exclusively on time series forecasting methods in this
chapter.

72

36
8/11/2022

Selecting a Time Series Forecasting


Method
• The underlying pattern in the time series is an important factor in selecting
a forecasting method.
• Thus, a time series plot should be one of the first things developed when
trying to determine what forecasting method to use.
• If we see a horizontal pattern, then we need to select a method
appropriate for this type of pattern.
• If we observe a trend in the data, then we need to use a method that has
the capability to handle trend effectively.

73

Forecast Accuracy
• Measures of forecast accuracy are used to determine how well a particular
forecasting method is able to reproduce the time series data that are
already available.
• Measures of forecast accuracy are important factors in comparing different
forecasting methods.
• By selecting the method that has the best accuracy for the data already
known, we hope to increase the likelihood that we will obtain better
forecasts for future time periods.

74

37
8/11/2022

Forecast Accuracy
• The key concept associated with measuring forecast accuracy is forecast
error.

Forecast Error = Actual Value (Y) – Forecast (F)

• A positive forecast error indicates the forecasting method underestimated


the actual value.
• A negative forecast error indicates the forecasting method overestimated
the actual value.

75

Forecast Accuracy
 Mean Error (ME)
• A simple measure of forecast accuracy is the mean or average of the
forecast errors.
∑ Y F
ME
n
• Because positive and negative forecast errors tend to offset one another,
the mean error is likely to be small. Thus, the mean error is not a very
useful measure.

76

38
8/11/2022

Forecast Accuracy
 Mean Absolute Error (MAE)
• It is the mean of the absolute values of the forecast errors.
∑ Y F
MAE
n
• This measure avoids the problem of positive and negative errors offsetting
one another.

77

Forecast Accuracy
 Mean Squared Error (MSE)
• This is another measure that avoids the problem of positive and negative
errors offsetting one another. It is the average of the squared forecast
errors.
∑ Y F
MSE
n

78

39
8/11/2022

Forecast Accuracy
 Mean Absolute Percentage Error (MAPE)
• The size of MAE and MSE depend upon the scale of the data, so it is
difficult to make comparisons for different time intervals. To make such
comparisons we need to work with relative or percentage error measures.
The MAPE is the average of the absolute percentage errors of the
forecasts.
𝑌 𝐹
∑ 𝑥100
𝑌
MAPE
𝑛

79

Time series forecasting methods


• Moving Average method
• Exponential Smoothing method
• Trend line Projection
• Time Series Decomposition

80

40
8/11/2022

The Moving-Average Model


• The k-period moving average builds a forecast by averaging the
observations in the most recent k periods:

Ft+1 = (yt + yt–1 + … + yt–k+1) / k


where yt represents the actual value of time series in period t;
Ft+1 denotes the forecast of the times series for period t + 1

81

The Moving-Average Model

• E.g. If Rosco Drugs uses a 3-period Week Sales Week Sales


moving average to forecast sales, 1 110 6 120
what are the forecasts for weeks 4- 2 115 7 130
11? 3 125 8 115
4 120 9 110
5 125 10 130

82

41
8/11/2022

The Moving-Average Model


Absolute
Forecast Absolute Square
Week Sales 3-MA Forecast Percent
Error Error Error
Error
A B C D E=B-D F= 𝑬 G=E2 H=(F/B)*100
1 110
2 115 116.7
3 125 120.0
4 120 123.3 116.7 3.3 3.3 10.89 2.75
5 125 121.7 120.0 5.0 5.0 25.00 4.00
6 120 125.0 123.3 -3.3 3.3 10.89 2.75
7 130 121.7 121.7 8.3 8.3 68.89 6.38
8 115 118.3 125.0 -10.0 10.0 100.00 8.70
9 110 118.3 121.7 -11.7 11.7 136.89 10.64
10 130 118.3 11.7 11.7 136.89 9.00
11 118.3
Sum 3.3 53.3 489.45 44.22

83

The Moving-Average Model


• Forecast Accuracy

53.3
MAE 7.61
7

489.45
MSE 69.92
7

44.22
MAPE 6.32%
7

84

42
8/11/2022

The Exponential Smoothing Model


• Exponential Smoothing Forecast

S αY 1 α S S α Y S

St+1: forecast of the time series for period t+1


Yt: actual value of the time series in period t
St: forecast of the time series for period t
α: smoothing constant (0 ≤ α ≤ 1)

85

The Exponential Smoothing Model


• E.g. If Rosco Drugs uses exponential smoothing to forecast sales, which
value for the smoothing constant α, 0.1 or 0.8, gives better forecasts?

86

43
8/11/2022

The Exponential Smoothing Model

𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭 𝐒𝐭 𝟏 𝛂𝐘𝐭 𝟏 𝛂 𝐒𝐭
Week Sales
with 𝛂= 0.1 with 𝛂= 0.8
1 110 110.00 110.00
2 115 110.00 110.00
3 125 110.50 114.00
4 120 111.95 122.80
5 125 112.76 120.56
6 120 113.98 124.11
7 130 114.58 120.82
8 115 116.12 128.16
9 110 116.01 117.63
10 130 115.41 111.53

87

The Exponential Smoothing Model


Forecast Forecast Absolute Square Absolute Percent
Week Sales
with 𝛂= 0.1 Error Error Error Error
A B C D=B-C E= 𝑫 F=D2 G=(E/B)*100
1 110 110.00
2 115 110.00 5.00 5.00 25.00 4.35
3 125 110.50 14.50 14.50 210.25 11.60
4 120 111.95 8.05 8.05 64.80 6.71
5 125 112.76 12.25 12.25 149.94 9.80
6 120 113.98 6.02 6.02 36.25 5.02
7 130 114.58 15.42 15.42 237.73 11.86
8 115 116.12 -1.12 1.12 1.26 0.98
9 110 116.01 -6.01 6.01 36.13 5.46
10 130 115.41 14.59 14.59 212.87 11.22
Sum 68.69 82.96 974.23 66.99

88

44
8/11/2022

The Exponential Smoothing Model


Forecast Forecast Absolute Square Absolute Percent
Week Sales
with 𝛂= 0.8 Error Error Error Error
A B C D=B-C E= 𝑫 F=D2 G=(E/B)*100
1 110 110.00
2 115 110.00 5.00 5.00 25.00 4.35
3 125 110.50 11.00 11.00 121.00 8.80
4 120 111.95 -2.80 2.80 7.84 2.33
5 125 112.76 4.44 4.44 19.71 3.55
6 120 113.98 -4.11 4.11 16.91 3.43
7 130 114.58 9.18 9.18 84.23 7.06
8 115 116.12 -13.16 13.16 173.30 11.45
9 110 116.01 -7.63 7.63 58.26 6.94
10 130 115.41 18.47 18.47 341.27 14.21
Sum 20.38 75.80 847.52 62.12

89

The Exponential Smoothing Model


• Forecast Accuracy
𝛂= 0.1 𝛂= 0.8
82.96 75.80
MAE 9.22 MAE 8.42
9 9
974.23 847.52
MSE 108.25 MSE 94.17
9 9
66.99 62.12
MAPE 7.44% MAPE 6.90%
9 9
Exponential smoothing (with 𝛼 = 0.8) provided more accurate forecasts than
ES with 𝛼 = 0.1, but less accurate than the 3-period moving average.

90

45
8/11/2022

Trend line Projection


• If a time series exhibits a linear trend, the method of least squares may be
used to determine a trend line (projection) for future forecasts.
• Least squares, also used in regression analysis, determines the unique
trend line forecast which minimizes the mean square error between the
trend line forecasts and the actual observed values for the time series.
• The independent variable is the time period and the dependent variable is
the actual observed value in the time series.

91

Trend line Projection


• The formula for the linear trend projection is

𝒀 𝒃𝟎 𝒃𝟏 𝒕

• For E.g. of Auger's Plumbing Service, forecast the number of repair jobs
Auger's will perform in December
• December, t=10.

𝑌 349.67 7.4𝑡 349.67 7.4 10 423.67

92

46
8/11/2022

Trend line Projection


Month Jobs (Y) t 𝒀 𝒀 𝒀 𝒀 𝒀 𝒀 𝒀 𝟐 Absolute Percent
Error
March 353 1 357.07 -4.07 4.07 16.56 1.15
Aprill 387 2 364.47 22.53 22.53 507.60 5.82
May 342 3 371.87 -29.87 29.87 892.22 8.73
June 374 4 379.27 -5.27 5.27 27.77 1.41
July 396 5 386.67 9.33 9.33 87.05 2.36
August 409 6 394.07 14.93 14.93 222.90 3.65
September 399 7 401.47 -2.47 2.47 6.10 0.62
October 412 8 408.87 3.13 3.13 9.80 0.76
November 408 9 416.27 -8.27 8.27 68.39 2.03
Sum -0.03 99.87 1838.40 26.53
99.87 1838.40 26.53
MAE 11.09 MSE 204.27 MAPE 2.95%
9 9 9
93

Time Series Decomposition


• In the case of time series patterns include trend and seasonal.
• Determine the deseasonalized data
• Determine a trend line of the deseasonalized data
• Determine the deseasonalized predictions
• Take into account the seasonality

94

47
8/11/2022

Additive model forecast


Seasonal adjusted
Year Quarter Actual Gasoline sales (Y) Adjustment S
time series (Y-S)
1 1 39 -17.92 56.92
2 37 2.28 34.72
3 61 16.95 44.05
4 58 -1.32 59.32
2 1 18 -17.92 35.92
2 56 2.28 53.72
3 82 16.95 65.05
4 27 -1.32 28.32
3 1 41 -17.92 58.92
2 69 2.28 66.72
3 49 16.95 32.05
4 66 -1.32 67.32
4 1 54 -17.92 71.92
2 42 2.28 39.72
3 90 16.95 73.05
4 66 -1.32 67.32

95

Additive model forecast


• Using the least squares method for t = 1, 2, ..., 16, the trend line of the
deseasonalized data is
𝒀𝒅 𝟒𝟐. 𝟔𝟎𝟏 𝟏. 𝟐𝟕𝟓𝟐𝒕
• Substitute t = 17, 18, 19 and 20 into the least squares equation, the
deseasonalized prediction values are
𝑌 42.601 1.2752 17 64.28
𝑌 42.601 1.2752 18 65.55
𝑌 42.601 1.2752 19 66.83
𝑌 42.601 1.2752 20 68.11

96

48
8/11/2022

Additive model forecast


• Each deseasonalized prediction plus its seasonal factor to give the
following forecasts year 5
• Quarter 1: Y 64.28 17.92 46.36
• Quarter 2: Y 65.55 2.28 67.83
• Quarter 3: Y 66.83 16.95 83.78
• Quarter 4: Y 68.11 1.32 66.79

97

Multiplicative Model Forecast


Seasonal adjusted
Year Quarter Actual Gasoline sales (Y) Adjustment S
time series (Y/S)
1 1 39 0.74244 52.53
2 37 0.97669 37.88
3 61 1.30894 46.60
4 58 0.97194 59.67
2 1 18 0.74244 24.24
2 56 0.97669 57.34
3 82 1.30894 62.65
4 27 0.97194 27.78
3 1 41 0.74244 55.22
2 69 0.97669 70.65
3 49 1.30894 37.43
4 66 0.97194 67.91
4 1 54 0.74244 72.73
2 42 0.97669 43.00
3 90 1.30894 68.76
4 66 0.97194 67.91
98

49
8/11/2022

Multiplicative Model Forecast


• Using the least squares method for t = 1, 2, ..., 16, the trend line of the
deseasonalized data is
𝒀𝒅 𝟒𝟏. 𝟏𝟕𝟓 𝟏. 𝟒𝟐𝟐𝟖𝒕
• Substitute t = 17, 18, 19 and 20 into the least squares equation, the
deseasonalized prediction values are
𝑌 41.175 1.4228 17 65.36
𝑌 41.175 1.4228 18 66.79
𝑌 41.175 1.4228 19 68.21
𝑌 41.175 1.4228 20 69.63

99

Multiplicative Model Forecast


• Multiply each deseasonalized prediction by its seasonal factor to give the
following forecasts year 5
• Quarter 1: Y 65.36 0.74244 48.53
• Quarter 2: Y 66.79 0.97669 65.23
• Quarter 3: Y 68.21 1.30894 89.28
• Quarter 4: Y 69.63 0.97194 67.68

100

50
8/11/2022

Note
• The trend line of the deseasonalized data can be linear or nonlinear
• Choose the best method based on forecast accuracy

101

Using SPSS
• Defining Dates: generates date variables used to establish periodicity and
to distinguish between historical, validation, and forecasting periods
• Data / Define Dates

102

51
8/11/2022

Using SPSS
• Determine the trend line regression
Analyze / Regression / Curve Estimation…

103

Using SPSS: Quadratic model


𝐑 𝐑𝟐 R2 = SSR/SST 𝐬𝐞 𝐬𝐞 𝟐 𝐌𝐒𝐄

With k=2 and n-k-1=17 MSR = SSR/k


degrees of freedom MSE = SSE/(n-k-1)

SSR

SSE
P-value
for F test
SST = SSR+SSE F = MSR/MSE
104

52
8/11/2022

Using SPSS: Quadratic model


P-value
b2 b1 for t test
of b1

b0

𝒔𝒃𝟏 P-value
𝒃𝟏 𝒃𝟐 for t test
𝒔𝒃𝟐 𝒕 𝒕
𝒔𝒃𝟏 of b2
𝒔𝒃𝟐
105

Using SPSS
 Choose the best line fit
• F or Sig F
• T test of coefficient b1, b2, … or Sig (P-value for t test)
• MSE min, R2 max

106

53
8/11/2022

Using SPSS
• Forecast based on the best line fit
Analyze > Regression > Curve Estimation > Save
Predicts for all cases in the
file

Predicts through the specified


date, time, or observation
number (may beyond the last
case in the time series)

107

Using SPSS Lower Confidence


Limits for Predicted
Actual Predicted values Upper Confidence
values values Limits for Predicted
Residuals values

108

54
8/11/2022

Summary
• Introduced time series and components of time series
• Described smooth techniques to smooth time series
• Discussed estimating the linear and nonlinear trend line
• Discussed finding seasonal variation
• Introduced forecasting and time series forecasting methods
• Selected the best forecasting method

109

55

You might also like