69
1 Time Series Analysis and Forecasting

Forcasting Techniques

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Forcasting Techniques

1

Time Series Analysisand Forecasting

Time Series Analysisand Forecasting

Page 2: Forcasting Techniques

2

Page 3: Forcasting Techniques

3

Introduction

Any variable that is measured over time in sequential order is called a time series.

We analyze time series to detect patterns.The patterns help in forecasting future

values of the time series.

The time series exhibit a downward trend pattern.

Predicted value

Page 4: Forcasting Techniques

4

20.1 Components of a Time Series

A time series can consist of four components. Long - term trend (T). Cyclical effect (C). Seasonal effect (S). Random variation (R).

A trend is a long term relatively smooth pattern or direction, thatpersists usually for more than one year.

Page 5: Forcasting Techniques

5

Components of a Time Series

A time series can consists of four components. Long - term trend (T) Cyclical variation (C) Seasonal variation (S) Random variation (R)

A cycle is a wavelike pattern describinga long term behavior (for more than one year).

Cycles are seldom regular, andoften appear in combination with other components.

6/90 6/93 6/96 6/99 6/02

Page 6: Forcasting Techniques

6

Components of a Time Series

A time series can consists of four components. Long - term trend (T). Cyclical effect (C). Seasonal effect (S). Random variation (R).

The seasonal component of the time seriesexhibits a short term (less than one year) calendar repetitive behavior.

6/97 12/97 6/98 12/98 6/99

Page 7: Forcasting Techniques

7

We try to remove random variation thereby, identify the other components.

Components of a Time Series

A time series can consists of four components. Long - term trend (T). Cyclical effect (C). Seasonal effect (S). Random variation (R).

Random variation comprises the irregular unpredictable changes in the time series.It tends to hide the other (more predictable)components.

Page 8: Forcasting Techniques

8

20.2 Smoothing Techniques

To produce a better forecast we need to determine which components are present in a time series.

To identify the components present in the time series, we need first to remove the random variation.

This can be done by smoothing techniques.

Page 9: Forcasting Techniques

9

Moving Averages

A k-period moving average for time period t is the arithmetic average of the time series values around period t.

– For example: A 3-period moving average at period t is calculated by (yt-1 + yt + yt+1)/3

Page 10: Forcasting Techniques

10

Moving Average: Example Example 20.1

To forecast future gasoline sales, the last four years quarterly sales were recorded.

Calculate the three-quarter and five-quarter moving average. Show the relevant graphs.

Xm20-01

Period Year/Quarter Gas Sales1 1 1 392 2 373 3 614 4 585 2 1 186 2 56

Page 11: Forcasting Techniques

11

Solution Solving by hand

Period Gas Sales

1 392 373 614 585 186 567 828 279 41

10 6911 4912 6613 5414 4215 9016 66

3-periodmoving Avg.

45.666752.000045.666744.000052.000055.000050.000045.666753.000061.333356.333354.000062.000066.0000

(39+37+61)/3=(37+61+58)/3=

5-periodmoving Avg.

42.600046.000055.000048.200044.800055.000053.600050.400055.800056.000060.200063.6000

(39+37+61+58+18)/5=

**

**

*

*

**

**

*

*

**

**

*

*

Moving Average: Example

Page 12: Forcasting Techniques

12

Moving Average

0

50

100

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Data Point

Va

lue

Notice how the averaging process removes some ofthe random variation.

Comment: We can identifya trend component .

Moving Average: Smoothing effect

3-period moving average

Page 13: Forcasting Techniques

13

Moving Average: Smoothing effect

The 5-period moving average removes more variation than the 3-period moving average.

0

20

4060

80

100

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

5-period moving average

0

20

4060

80

100

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

3-period moving average

Page 14: Forcasting Techniques

14

Centered Moving Average

With an even number of observations included in the moving average, the average is placed between the two periods in the middle.

To place the moving average in an actual time period, we need to center it.

Two consecutive moving averages are centered by taking their average, and placing it in the middle between them. (This is used to graph the points.)

Page 15: Forcasting Techniques

15

Calculate the 4-period moving average and center it, for the data given below:

Period Time series Moving Avg. Centerd Mov.Avg.1 152 273 204 145 256 11

Centered Moving Average: Example

19.020.25

21.5

(2.5)

(3.5)19.5017.5(4.5)

Page 16: Forcasting Techniques

16

– The moving average method does not provide smoothed values (moving average values) for the first and last set of periods.

Exponential Smoothing

The exponential smoothing method provides smoothed values for all the time periods observed.

the moving average method considers only the observations included in the calculation of the average value, and “forgets” the rest.

– When smoothing the time series at time t, > the exponential

smoothing method considers all the data available at t (yt, yt-1,…)

Page 17: Forcasting Techniques

17

Exponentially Smoothed Time Series

St = exponentially smoothed time series at time t.yt = time series at time t.

St-1 = exponentially smoothed time series at time t-1.

w = smoothing constant, where 0 w 1.

St = wyt + (1-w)St-1St = wyt + (1-w)St-1

Page 18: Forcasting Techniques

18

Example 20.2 (Xm20-01)

Period Gas Sales

1 392 373 614 585 186 56. .. .

Calculate the gasoline sale smoothed time series using exponential smoothing with w = .2, and w = .7.

Set S1 = y1 S1 = 39

S3 = wy3 + (1-w)S2 S3 = (.2)(61) + (1-.2)(38.6) = 43.1

The Exponentially Smoothed Process

S2 = wy2 + (1-w)S1 S2 = (.2)(37) + (1-.2)(39) = 38.6

Page 19: Forcasting Techniques

19

Example 20.2-continuedExponential Smoothing, w=.2

0

50

100

1 3 5 7 9

11 13 15

Val

ue

Exponential Smoothing , w=.7

0

50

100

1 3 5 7 9 11 13 15

Val

ue

Small ‘w’ provides a lot of smoothing

The Exponentially Smoothed Process

Neither value of ‘w’reveals the seasonality.

Page 20: Forcasting Techniques

20

The Exponentially Smoothed Process

We will let Minitab do our exponential smoothing

Stat>Time Series > Single Exp Smoothing

This will give us the smoothed graph

Page 21: Forcasting Techniques

21

20.3 Trend and Seasonal EffectsTrend Analysis

The trend component of a time series can be linear or non-linear.

It is easy to isolate the trend component using linear regression. For linear trend use the model y = 0 + 1t

+ For non-linear trend with one (major)

change in slope use the quadratic model y = 0 + 1t + 2t2 +

Page 22: Forcasting Techniques

22

Seasonal Analysis

Seasonal variation may occur within a year or within a shorter period (month, week)

To measure the seasonal effects we construct seasonal indexes.

Seasonal indexes express the degree to which the seasons differ from the average time series value across all seasons.

Page 23: Forcasting Techniques

23

Computing Seasonal Indexes

Remove the effects of the seasonal and random variations by regression analysis

= b0 + b1t

• For each time period compute the ratioyt/yt

which removes most of the trend variation >

• For each season calculate the average of yt/yt

which provides the measure of seasonality.• Adjust the average above so that the sum of averages

of all seasons is 1 (if necessary)

>

This is based on the Multiplicative Model.

ty

Page 24: Forcasting Techniques

24

The additive and multiplicative models

There are two mostly used general models to describe the composition of a time series

The multiplicative model

The additive model yt = Tt + St + Rt

In the seasonal index analysis performed here we use the multiplicative model because it is mathematically easier to handle.

tttt RSTy (Assuming no cyclical effects).

Page 25: Forcasting Techniques

25

ttt

ttt

t

t RST

RSTyy

Seasonal indexes analysis

The multiplicative model

The regression line represents trend.

• We see that the ratio represents the seasonality and the random effects.

• Averaging these ratios for each season type removes the random effects and leaves the seasonality.

t

t

yy

Page 26: Forcasting Techniques

26

ttt

ttt

t

t RST

RSTyy

Seasonal indexes analysis

The multiplicative model

Rate/Predicted rate

0

0.5

1

1.5

1 3 5 7 9 11 13 15 17 19

Note how no trend is observed, butseasonality and randomnessstill exist.

• Averaging the ratios for each season type removes the random effects and leaves the seasonality.t

t

yy

Page 27: Forcasting Techniques

27

Computing Seasonal Indexes

Example 20.3 (Xm20-03) Calculate the quarterly seasonal

indexes for hotel occupancy rate in order to measure seasonal variation.

Data:Year Quarter Rate Year Quarter Rate Year Quarter Rate

1996 1 0.561 1998 1 0.594 2000 1 0.6652 0.702 2 0.738 2 0.8353 0.8 3 0.729 3 0.8734 0.568 4 0.6 4 0.67

1997 1 0.575 1999 1 0.6222 0.738 2 0.7083 0.868 3 0.8064 0.605 4 0.632

Page 28: Forcasting Techniques

28

0 5 10 15 20 25

t

Rat

e

Perform regression analysis for the modely = 0 + 1t + where t represents the time, and y represents the occupancy rate.

Time (t) Rate1 0.5612 0.7023 0.8004 0.5685 0.5756 0.7387 0.8688 0.605 . . . .

t005246.639368.y

The regression line represents trend.

Computing Seasonal IndexesRationale for seasonal indexes

Page 29: Forcasting Techniques

29

t yt Ratio1 .561 .645 .561/.645=.8702 .702 .650 .702/.650=1.083 ………………………………………………….

Rate/Predicted rate

0

0.5

1

1.5

1 3 5 7 9

11

13

15

17

19

No trend is observed, butseasonality and randomnessstill exist.

t

t

yy

ty

=.639368+.005245(1)

The Ratios yt yt

>

Page 30: Forcasting Techniques

30

The Average Ratios by Seasons

Rate/Predicted rate

0

0.5

1

1.5

1 3 5 7 9 11 13 15 17 19

Rate/Predicted rate0.8701.0801.2210.8600.8641.1001.2840.8880.8651.0671.0460.8540.8790.9931.1220.8740.9131.1381.1810.900

Rate/Predicted rate0.8701.0801.2210.8600.8641.1001.2840.8880.8651.0671.0460.8540.8790.9931.1220.8740.9131.1381.1810.900

(.870 + .864 + .865 + .879 + .913)/5 = .878Average ratio for quarter 1:

Average ratio for quarter 2: (1.080+1.100+1.067+.993+1.138)/5 = 1.076

Average ratio for quarter 3: (1.221+1.284+1.046+1.122+1.181)/5 = 1.171

Average ratio for quarter 4: (.860 +.888 + .854 + .874 + .900)/ 5 = .875

• To remove most of the random variation but leave the seasonal effects,average the terms for each season.tt yy ˆ/

Page 31: Forcasting Techniques

31

In this example the sum of all the averaged ratios must be 4, such that the average ratio per season is equal to 1.

If the sum of all the ratios is not 4, we need to adjust them proportionately.

(Seasonal averaged ratio) (number of seasons) Sum of averaged ratiosSeasonal index =

In our problem the sum of all the averaged ratios is equal to 4:.878 + 1.076 + 1.171 + .875 = 4.0.No normalization is needed. These ratios become the seasonal indexes.

Suppose the sum of ratios is equal to 4.1. Then eachratio will be multiplied by 4/4.1.

Adjusting the Average Ratios

Page 32: Forcasting Techniques

32

Quarter 2 Quarter 3Quarter 3Quarter 2

The seasonal indexes tell us what is the ratio between the time series value at a certain season, and the overall seasonal average.

In our problem:Annual averageoccupancy (100%)

Quarter 1 Quarter 4 Quarter 1 Quarter 4

87.8%107.6%

117.1%

87.5%12.2% below theannual average

7.6% above theannual average

17.1% above theannual average

12.5% below theannual average

Interpreting the Seasonal Indexes

Page 33: Forcasting Techniques

33

The trend component and the seasonality component are recomposed using the multiplicative model.

0.5

0.6

0.7

0.8

0.9

1 3 5 7 9 11 13 15 17 19

tttt StSTy ˆ)0052.639(.ˆˆˆ

In period #1 ( quarter 1): 566.)878))(.1(0052.639(.STy 111 In period #2 ( quarter 2): 699.)076.1))(2(0052.639(.STy 222

Actual series Smoothed series

The linear trend (regression) line

The Smoothed Time Series

Page 34: Forcasting Techniques

34

Deseasonalized Time Series

By removing the seasonality, we can identify changes in the other components of the time series, that might have occurred over time.

Seasonally adjusted time series = Actual time seriesSeasonal index

Page 35: Forcasting Techniques

35

Deseasonalized Time Series

In period #1 ( quarter 1): 639.870./561.SI/y 11 In period #2 ( quarter 2): 652.076.1708.SI/y 22

0

0.2

0.4

0.6

0.8

1

0 5 10 15 20 25

There was a gradual increase in occupancy rateIn period #5 ( quarter 1): 661.870.575.SI/y 15

Page 36: Forcasting Techniques

36

20.4 Introduction to Forecasting

**

***

*

** o

oo

o oo

oo

Model 1 Model 2

Which model performs better?

There are many forecasting models available

?

Page 37: Forcasting Techniques

37

A forecasting method can be selected by evaluating its forecast accuracy using the actual time series.

n

Fy

MAD

n

1ttt

n

1t

2tt )Fy(SSE

The two most commonly used measures of forecast accuracy are:

Mean Absolute Deviation

Sum of Squares for Forecast Error

20.4 Introduction to Forecasting

Page 38: Forcasting Techniques

38

Choose SSE if it is important to avoid (even a few) large errors. Otherwise, use MAD.

A useful procedure for model selection.Use some of the observations to develop several competing forecasting models.Run the models on the rest of the observations.Calculate the accuracy of each model (by comparing to actual data at a later time period).Select the model with the best (lowest) accuracy measure.

Measures of Forecast Accuracy

Page 39: Forcasting Techniques

39

Selecting a Forecasting Model

Annual data from 1970 to 1996 were used to develop three forecasting models.

Use MAD and SSE to determine which model performed best for 1997, 1998, 1999, and 2000.

Forecast valueYear Actual y Model 1 Model 2 Model 3

1997 129 136 118 1301998 142 148 141 1461999 156 150 158 1702000 183 175 163 180

Page 40: Forcasting Techniques

40

Model 1 Model 2 Model 3MAD 6.75 8.5 5.5SSE 185 526 222

Solution For model 1

185)175183()160156()148142()136129(SSE

75.6MAD

22224

175183150156148142136129

Summary of results

Actual yin 1991

Forecast for y in 1991

Page 41: Forcasting Techniques

41

Selecting a Forecasting Model

In this case, Model 2 is inferior to both Models 1 and 3

Using MAD Model 3 is bestUsing SSE Model 1 is most accurateChoice – prefer model that consistently

produces moderately accurate forecasts (Model 3) or one whose forecasts come quite close usually but misses badly in a small number of time periods (Model 1)

Page 42: Forcasting Techniques

42

The choice of a forecasting technique depends on the components identified in the time series.

The techniques discussed next are: Exponential smoothing Seasonal indexes Autoregressive models (a brief discussion)

20.5 Forecasting Models

Page 43: Forcasting Techniques

43

The exponential smoothing model can be used to produce forecasts when the time series… exhibits gradual(not a sharp) trend no cyclical effects no seasonal effects

Forecast for period t+k is computed by

Ft+k = St

t is the current period; St = yt + (1-)St-1

Forecasting with Exponential Smoothing

Page 44: Forcasting Techniques

44

Forecasting with Exponential Smoothing - Example

The quarterly sales (in $ millions) of a department store chain were recorded for the years 1997 – 2000

Page 45: Forcasting Techniques

45

Forecasting with Exponential Smoothing - Example

Quarter 1997 1998 1999 2000

1 18 33 25 41

2 22 20 36 33

3 27 38 44 52

4 31 26 29 45

Page 46: Forcasting Techniques

46

Forecasting with Exponential Smoothing - Example

Index

Sale

s

161412108642

55

50

45

40

35

30

25

20

Smoothing ConstantAlpha 0.4

Accuracy MeasuresMAPE 22.4486MAD 7.2311MSD 69.2590

VariableActualFits

Single Exponential Smoothing Plot for Sales

S16 = 41.8

Y16 = 45

Page 47: Forcasting Techniques

47

Forecasting with Exponential Smoothing - Example

Forecast for period t+k is computed by

(t = 16) Ft+k = St

t is the current period; St = yt + (1-)St-1

F17= S16 = 41.8

F18= S16 = 41.8

F19= S16 = 41.8

F20= S16 = 41.8

Page 48: Forcasting Techniques

48

Computing Seasonal Indexes

Example 20.3 (Xm20-03) Calculate the quarterly seasonal

indexes for hotel occupancy rate in order to measure seasonal variation.

Data:Year Quarter Rate Year Quarter Rate Year Quarter Rate

1996 1 0.561 1998 1 0.594 2000 1 0.6652 0.702 2 0.738 2 0.8353 0.8 3 0.729 3 0.8734 0.568 4 0.6 4 0.67

1997 1 0.575 1999 1 0.6222 0.738 2 0.7083 0.868 3 0.8064 0.605 4 0.632

tttt StSTy ˆ)0052.639(.ˆˆˆ

Page 49: Forcasting Techniques

49

Forecasting with Seasonal Indexes; Example

The solution procedureUse simple linear regression to find the trend line.Use the trend line to calculate the trend values.To calculate Ft multiply the trend value for period t by the seasonal index of period t.

Example 20.5 Use the seasonal indexes calculated in

Example 21.3 along with the trend line, to forecast each quarter occupancy rate in 2001.

Page 50: Forcasting Techniques

50

Forecasting with Seasonal Indexes; Example

The solution procedure1. Use simple linear regression to find the trend

line.

From Minitab (Using decomposition )Yt = .639 + .00525t

Page 51: Forcasting Techniques

51

Forecasting with Seasonal Indexes; Example

The solution procedure:

We previously used 20 time periodsQuarter 1: 0.639 + 0.00525(21) = 0.749Quarter 2: 0.639 + 0.00525(22) = 0.755Quarter 3: 0.639 + 0.00525(23) = 0.760Quarter 4: 0.639 + 0.00525(24) = 0.765

2. Use the trend line to calculate the trend values

Yt = .639 + .00525t

Page 52: Forcasting Techniques

52

Forecasting with Seasonal Indexes; Example

The solution procedure3. To calculate Ft multiply the trend value for

period t by the seasonal index of period t.

Quarter 1: 0.749 X 0.878 = 0.658Quarter 2: 0.755 X 1.076 = 0.812Quarter 3: 0.760 X 1.171 = 0.890Quarter 4: 0.765 X 0.875 = 0.670We forecast that the quarterly occupancy

rates for the next year will be 65.8%, 81.2%, 89% and 67%.

Page 53: Forcasting Techniques

53

Solution The trend line was obtained from the

regression analysis.

Forecasting with Seasonal Indexes: Example (Summary)

t00525.639.y t

t Trend value Quarter SI Forecast21 .749 1 .878 .65822 .755 2 1.076 .81223 .760 3 1.171 .89024 .765 4 .875 .670

749.)21(00525.639.ˆ21 y F21 = .749(.878)

– For the year 2001 we have:

Page 54: Forcasting Techniques

54

Problem 20-47

The revenues (in $millions) of a chain of ice-cream stores are listed for each quarter during the previous 5 years.

Use the handout with the plots etc. to answer the questions.

Page 55: Forcasting Techniques

55

Quarter 1996 1997 1998 1999 2000

1 16 14 17 18 21

2 25 27 31 29 30

3 31 32 40 45 52

4 24 23 27 24 32

Page 56: Forcasting Techniques

56

20-47

1. Plot the time series. Is there a pattern? Does there appear to be A long term trend A cyclic effect A seasonal effect

2. Plot the 3-year moving balance. Does this change any of your answers from # 1?

Page 57: Forcasting Techniques

57

20-47 - Answers

Seems to be a long term trend – going upward.

Does not seem to be a cyclic effect. Because we know the data is in quarter years, this seems to be a strong seasonal effect.

The three year moving average plot strengthens these observations.

Page 58: Forcasting Techniques

58

20-47

Why is exponential smoothing not recommended as a forecasting tool in this problem?

Look at the exponential smoothing plot (w = 0.3) Does this confirm your answer above?

Page 59: Forcasting Techniques

59

20-47 - Answers

Exponential smoothing is not recommended as a forecasting tool for this problem because of the strong seasonal effect.

The 0.3 gives a large smoothing effect, and the seasonality is no larger as evident.

Page 60: Forcasting Techniques

60

20-47

Look at the trend analysis plots. Does the Linear or the Quadratic trend model seem to be better? Why? What is the equation of the trend line?

Page 61: Forcasting Techniques

61

20-47 - Answers

The linear model seems to fit well. The quadratic model doesn’t show much of a curve. Checking the MAD for both models shows 6.8716 for the linear model and 6.8784 for the quadratic model. Since the linear model has a slightly smaller MAD we will use it.

The equation of the trend line, then, is Y = 20.2105 + 0.732331t

Page 62: Forcasting Techniques

62

20.47

Predict the sales for the next 4 quarters using the trend analysis line.

Page 63: Forcasting Techniques

63

20-47 - Answer

The next 4 quarters are numbers 21, 22, 23, 24

Y = 20.21 + 0.732 tY21 = [20.21 + 0.732 (21)] = 35.58

Y22 = [20.21 + 0.732 (22)] = 36.31

Y23 = [20.21 + 0.732 (23)] = 37.05

Y24 = [20.21 + 0.732 (24)] = 37.78

Page 64: Forcasting Techniques

64

20-47

Using the seasonal indexes and the trend line, forecast revenues for the next four quarters.

Page 65: Forcasting Techniques

65

20-47 - AnswerThe Fitted trend equation for the decomposition

plot is Y = 21.7511 + 0.567732 tThe next time period is number 21.Y21 = [21.75 + 0.568 (21)] * 0.63581 = 21.41

Y22 = [21.75 + 0.568 (22)] * 1.05732 = 36.21

Y23 = [21.75 + 0.568 (23)] * 1.36851 = 47.64

Y24 = [21.75 + 0.568 (24)] * 0.93835 = 33.20

Page 66: Forcasting Techniques

66

20-47 (continued)

If the actual sales numbers for the next four quarters were 24, 40, 48, 36. Calculate the MAD for the predictions from the trend line and seasonal indexes.

Page 67: Forcasting Techniques

67

20-47 - Answer

MAD = |21.41 - 24| + |36.21 – 40| + |47.46 – 48| + |33.2 – 36| / 4

= (2.59 + 3.79 + .54 + .2.8 ) / 4= 9.72/4 = 2.43

Page 68: Forcasting Techniques

68

20-47

Go back to the linear trend equation forecasts. If the actual sales numbers for the next four quarters were 24, 40, 48, 36. Calculate the MAD.

Which method of forecasting did a better job in this case?

Page 69: Forcasting Techniques

69

20-47 Answers

MAD = |35.58 - 24| + |36.31 – 40| + |37.05 – 48| + |37.78 – 36| / 4

= (11.58 + 3.69 + 10.95 + 1.78 ) / 4= 28/4 = 7 This is the MAD for the trend

analysis.The MAD for the seasonal trend analysis

was 2.43.The seasonal trend analysis did the better

job of forecasting.