time series analysis for e-business. “forecasting is very dangerous, especially about the...

60
Time Series Analysis for e- business

Upload: briana-booker

Post on 16-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Time Series Analysis for e-business

Page 2: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn
Page 3: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

“ Forecasting is very dangerous, especially

about the future.”

--- Samuel Goldwyn

Page 4: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Introduction to Time Series Analysis

• A time-series is a set of observations on a quantitative variable collected over time.

• Examples Dow Jones Industrial Averages Historical data on sales, inventory, customer

counts, interest rates, costs, etc• Businesses are often very interested in

forecasting time series variables.• Often, independent variables are not available to

build a regression model of a time series variable.• In time series analysis, we analyze the past

behavior of a variable in order to predict its future behavior.

Page 5: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

• Good forecasts can lead to– Reduced inventory costs.– Lower overall personnel costs.– Increased customer satisfaction.

• The Forecasting process can be based on– Educated guess.– Expert opinions.– Past history of data values, known as a

time series.

Page 6: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting is fundamental to decision-making. There are three main methods:

• Subjective forecasting is based on experience, intuition, guesswork and a good supply of envelope-backs.

• Extrapolation is forecasting with a rule where past trends are simply projected into the future.

• Causal modeling (cause and effect) uses established relationships to predict, for example, sales on the basis of advertising or prices.

Page 7: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Some Time Series Terms

• Stationary Data - a time series variable exhibiting no significant upward or downward trend over time.

• Nonstationary Data - a time series variable exhibiting a significant upward or downward trend over time.

• Seasonal Data - a time series variable exhibiting a repeating patterns at regular intervals over time.

Page 8: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Stationarity

Page 9: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Non-stationarity (upward trend)

0

1

2

3

4

5

6

7

Page 10: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

• Components of a Time Series– Long Term Trend

• A time series may be stationary or exhibit trend over time.• Long term trend is typically modeled as a linear, quadratic

or exponential function.

– Seasonal Variation • When a repetitive pattern is observed over some time

horizon, the series is said to have seasonal behavior.• Seasonal effects are usually associated with calendar or

climatic changes.• Seasonal variation is frequently tied to yearly cycles.

– Cyclical Variation• An upturn or downturn not tied to seasonal variation.• Usually results from changes in economic conditions.

– Random effects

Page 11: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Trend Component

The long-term tendency is usually one of three: growth, decline, or constant.

Reasons for trends include:

Population growth -- greater demand for products and services-- greater supply of products and services

Technology -- impacts on efficiency, supply, and demand

Innovation -- impacts efficiency as well as supply and demand

Page 12: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Seasonal Component

Upward and downward movements which repeat at the same time each year.

Reasons for seasonal influences include:

Weather -- both outdoor and indoor activities can impact demand because of the number of people involved-- supplies of products and services may depend on the weather

Events, Holidays -- often impact supply and demand

Page 13: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Cyclical Component

Similar to seasonal variations except that there is likely not arelationship to the time of the year.

Examples of cyclical influences include:

Inflation/deflation -- energy costs, wages and salaries, and government spending

Stock market prices -- bull markets, bear markets

Consequences of unique events -- severe weather, law suits

Page 14: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Irregular Component

Unexplained variations which we usually treat as randomness.

This is the equivalent of the error term in the analysis of variance model and the regression model.

These are short-term effects, usually. We treat them as independent from one time period to the next. The length ofthe duration of these effects would then be shorter than one time period, that is, one month for monthly data, one year forannual data.

Page 15: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Time-Series Model• The four components of time series come

together to form a time series model.• There are two popular time series models:

– Additive Model:

– Multiplicative Model:

Where Tt is the trend, St is the seasonal, Ct is the cyclical and It is the irregular component.

ttttt ICSTY

))()()(( ttttt ICSTY

Page 16: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Typical Time Series patternsTypical Time Series patterns

A Stationary Time Series

Linear trend time seriesNon linear trend time seriesLinear Trend and Seasonality time series

Page 17: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Approaching Time Series Analysis• There are many, many different time series

techniques.• It is usually impossible to know which

technique will be best for a particular data set.

• It is customary to try out several different techniques and select the one that seems to work best.

• To be an effective time series modeler, you need to keep several time series techniques in your “tool box.”

Page 18: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Measuring Accuracy• We need a way to compare different time series techniques for a given data set.• Four common techniques are the:

– mean absolute deviation,

– mean absolute percent error,

– the mean square error,

– root mean square error.

MAD = Y Yi i

i

n

n

1

MSE =

Y Yi i

i

n

n

2

1

MSERMSE

n

i i

ii

n 1 Y

YY100 = MAPE

We will focus on the MSE.

Page 19: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Extrapolation Models• Extrapolation models try to account for the past

behavior of a time series variable in an effort to predict the future behavior of the variable.

, , ,Y Y Y Yt t t tf 1 1 2

• We’ll first talk about several extrapolation techniques that are appropriate for stationary data.

Page 20: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

An Example• Electra-City is a retail store that sells audio

and video equipment for the home and car. • Each month the manager of the store must

order merchandise from a distant warehouse.

• Currently, the manager is trying to estimate how many VCRs the store is likely to sell in the next month.

• He has collected 24 months of data.

Page 21: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Moving Averages

YY Y Yt t-1 t- +1

tk

k

1

• No general method exists for determining k.

• We must try out several k values to see what works best.

Page 22: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

A Comment on Comparing MSE Values

• Care should be taken when comparing MSE values of two different forecasting techniques.

• The lowest MSE may result from a technique that fits older values very well but fits recent values poorly.

• It is sometimes wise to compute the MSE using only the most recent values.

Page 23: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Moving Average Model

.YY Y

2

36 + 35

22524 23 355

Forecasts for time periods 25 and 26 at time period 24:

.YY Y

2

35.5+ 36

22625 24 3575

Page 24: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Weighted Moving Average• The moving average technique assigns

equal weight to all previous observations

Y1

Y1

Y1

Yt t-1 t- -1t kk k k 1

• The weighted moving average technique allows for different weights to be assigned to previous observations.

Y Y Y Yt t-1 t- -1t k kw w w 1 1 2

where 0 and w wi i1 1

• We must determine values for k and the wi

Page 25: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Weighted Moving Average Model

29.3535709.036291.0YYY 23224125 ww

Forecasts for time periods 25 and 26 at time period 24:

79.3536709.029.35291.0YYY 24225126 ww

Page 26: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Exponential Smoothing

( )Y Y Y Yt t t t 1 where 0 1

• It can be shown that the above equation is equivalent to: ( ) ( ) ( )Y Y Y Y Yt t t t

nt n 1 1

221 1 1

Page 27: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Examples of TwoExponential Smoothing Functions

28

30

32

34

36

38

40

42

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Time Period

Un

its

So

ld

Number of VCRs Sold

Exp. Smoothing alpha=0.1

Exp. Smoothing alpha=0.9

Page 28: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Exponential Smoothing Model

81.35)74.3536(268.074.35)YY(YY 24242425

Forecasts for time periods 25 and 26 at time period 24:

81.35Y)YY(Y)YY(YY 2525252525252526

. ,Y for = 25, 26, 27, t t3581

Note that,

Page 29: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Seasonality• Seasonality is a regular, repeating

pattern in time series data.• May be additive or multiplicative in

nature...

Page 30: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Multiplicative Seasonal Effects

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Time Period

Additive Seasonal Effects

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Time Period

Stationary Seasonal Effects

Page 31: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn
Page 32: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Seasonal Variation

Monthly Sales of Sun Tan Oil

0

50

100

150

200

250

0 5 10 15 20 25 30 35

Months (January 1993-August 1995)

Un

its

so

ld (

in t

ho

us

an

ds

)

Page 33: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Stationary Data With Additive Seasonal Effects

pnttnt SEYwhere

1)E-(1)S-Y(E tt-ptt

ptttt )S-(1)E-Y(S

10

10

p represents the number of seasonal periods

• Et is the expected level at time period t.• St is the seasonal factor for time period t.

Page 34: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The AdditiveSeasonal Effects Model

Forecasts for time periods 25 to 28 at time period 24:

4242424 SEY nn

00.36345.844.354SEY 212425

73.33682.1744.354SEY 222426

13.40158.4644.354SEY 232427

81.32273.3144.354SEY 242428

Page 35: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Stationary Data With Multiplicative Seasonal Effects

pnttnt SEYwhere

1)E-(1)/SY(E tt-ptt

ptttt )S-(1)/EY(S

10

10

p represents the number of seasonal periods

• Et is the expected level at time period t.• St is the seasonal factor for time period t.

Page 36: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The MultiplicativeSeasonal Effects Model

Forecasts for time periods 25 to 28 at time period 24:

4242424 SEY nn

13.359015.195.353SEY 212425

94.334946.044.354SEY 222426

99.400133.144.354SEY 232427

95.322912.044.354SEY 242428

Page 37: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Trend Models

• Trend is the long-term sweep or general direction of movement in a time series.

• We’ll now consider some nonstationary time series techniques that are appropriate for data exhibiting upward or downward trends.

Page 38: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

An Example• WaterCraft Inc. is a manufacturer of

personal water crafts (also known as jet skis).

• The company has enjoyed a fairly steady growth in sales of its products.

• The officers of the company are preparing sales and manufacturing plans for the coming year.

• Forecasts are needed of the level of sales that the company expects to achieve each quarter.

Page 39: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Double Moving Average

• Et is the expected base level at time

period t.

• Tt is the expected trend at time period t.

ttnt nTEY

wherettt DM2E

)1/()DM(2T kttt

kktttt /)(M YYY 11

kktttt /)(D MMM 11

Page 40: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Double Moving Average Model

Forecasts for time periods 21 to 24 at time period 20:

23.25259.139133.2385T1EY 202021

202020 TEY nn

13.26659.139233.2385T2EY 202022

03.28059.139333.2385T3EY 202023

94.29449.139433.2385T4EY 202024

Page 41: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Double Exponential Smoothing(Holt’s Method)

• Et is the expected base level at time period t.

• Tt is the expected trend at time period t.

ttnt nTEY

where

Et = Yt + (1-)(Et-1+ Tt-1)

Tt = (Et Et-1) + (1-) Tt-10 1 1 and 0

Page 42: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With Holt’s Model

Forecasts for time periods 21 to 24 at time period 20:

. . .Y E T21 20 201 2336 8 1 1521 2488 9 . . .Y E T22 20 202 23368 2 1521 26410 . . .Y E T23 20 203 2336 8 3 152 1 27931 . . .Y E T24 20 204 2336 8 4 152 1 2945 2

202020 TEY nn

Page 43: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Holt-Winter’s Method For Additive Seasonal Effects

pntttnt n STEY

where

)T)(E-(1SYE 11 ttpttt 11 )T-(1EET tttt ptttt )S-(1EYS

10

10

10

Page 44: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With Holt-Winter’s Additive Seasonal Effects Method

Forecasts for time periods 21 to 24 at time period 20:

420202020 STEY nn n

2670.366.2623.15413.2253ST1EY 17202021

3.224959.3123.15423.2253ST2EY 18202022

6.292140.2053.15433.2253ST3EY 19202023

6.325612.3863.15443.2253ST4EY 20202024

Page 45: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Holt-Winter’s Method For Multiplicative Seasonal Effects

pntttnt n STEYwhere

)T)(E-(1S/YE 11 ttpttt 11 )T-(1EET tttt ptttt )S-(1E/YS

10

10

10

Page 46: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With Holt-Winter’s Multiplicative Seasonal Effects

MethodForecasts for time periods 21 to 24 at time period

20:

7.2713152.1)3.13716.2217()T1E(Y 17202021 S

9.2114849.0)3.13726.2217()T2E(Y 18202022 S

5.2900103.1)3.13736.2217()T3E(Y 19202023 S

9.3293190.1)3.13746.2217()T4E(Y 20202024 S

420202020 S TEY nn n

Page 47: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Linear Trend Model

Y Xt b bt

0 1 1

tt1X where

For example:

X X X 1 1 11 2 31 2 3 , , ,

Page 48: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Linear Trend Model

Forecasts for time periods 21 to 24 at time period 20:

. . .Y X21 0 1 1213751 92 6255 21 2320 3 b b

. . .Y X22 0 1 1223751 92 6255 22 2412 9 b b

. . .Y X23 0 1 1233751 92 6255 23 2505 6 b b

. . .Y X24 0 1 1243751 92 6255 24 2598 2 b b

Page 49: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The TREND() FunctionTREND(Y-range, X-range, X-value for prediction)where: Y-range is the spreadsheet range containing the dependent Y variable, X-range is the spreadsheet range containing the independent X variable(s), X-value for prediction is a cell (or cells) containing the values for the independent X variable(s) for which we want an estimated value of Y.

Note: The TREND( ) function is dynamically updated whenever any inputs to the function change. However, it does not provide the statistical information provided by the regression tool. It is best two use these two different approaches to doing regression in conjunction with one another.

Page 50: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

The Quadratic Trend Model

Y X Xt b b bt t

0 1 1 2 2

where X and X1 22

t tt t

Page 51: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Quadratic Trend Model

Forecasts for time periods 21 to 24 at time period 20:

9.259821617.321671.1667.653XXY 22211021 2121

bbb

1.277122617.322671.1667.653XXY 22211022 2222

bbb

4.295023617.323671.1667.653XXY 22211023 2323

bbb

1.313724617.324671.1667.653XXY 22211024 2424

bbb

Page 52: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Computing Multiplicative Seasonal Indices

• We can compute multiplicative seasonal adjustment indices for period p as follows:

S

Y

Y, for all occuring in season p

i

ii

pni p

• The final forecast for period i is then

Y adjusted = Y S , for any occuring in season i i p i p

Page 53: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With Seasonal Adjustments Applied To Our

Quadratic Trend ModelForecasts for time periods 21 to 24 at time period 20:

8.2747%7.1059.2598)XX(Y 12211021 2121 Sbbb

6.2219%1.801.2771)XX(Y 22211022 2222 Sbbb

4.3041%1.1035.2950)XX(Y 32211023 2323 Sbbb

1.3486%1.1112.3137)XX(Y 42211024 2424 Sbbb

Page 54: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Summary of the Calculation and Use of Seasonal Indices

1. Create a trend model and calculate the estimated value ( ) for each observation in the sample.

2. For each observation, calculate the ratio of the actual value to the predicted trend value:

(For additive effects, compute the difference:

3. For each season, compute the average of the ratios calculated in step 2. These are the seasonal indices.

4. Multiply any forecast produced by the trend model by the appropriate seasonal index calculated in step 3. (For additive seasonal effects, add the appropriate factor to the forecast.)

tY

.Y/Y tt

).YY tt

Page 55: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Refining the Seasonal Indices• Note that Solver can be used to

simultaneously determine the optimal values of the seasonal indices and the parameters of the trend model being used.

• There is no guarantee that this will produce a better forecast, but it should produce a model that fits the data better in terms of the MSE.

Page 56: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Seasonal Regression Models• Indicator variables may also be used in regression

models to represent seasonal effects.• If there are p seasons, we need p -1 indicator variables.

• Our example problem involves quarterly data, so p=4 and we define the following 3 indicator variables:

X if Y is an observation from quarter 2

otherwise4

1

0t

t

,

,

X if Y is an observation from quarter 1

otherwise3

1

0t

t

,

,

X if Y is an observation from quarter 3

otherwise5

1

0t

t

,

,

Page 57: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Implementing the Model• The regression function is:

Y X X X X Xt b b b b b bt t t t t

0 1 1 2 2 3 3 4 4 5 5

where X and X1 22

t tt t

Page 58: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Forecasting With The Seasonal Regression Model

Forecasts for time periods 21 to 24 at time period 20:

5.2638)0(453.123)0(736.424)1(805.86)21(485.3)21(319.17471.824Y 221

7.2467)0(453.123)1(736.424)0(805.86)22(485.3)22(319.17471.824Y 222

2.2943)1(453.123)0(736.424)0(805.86)23(485.3)23(319.17471.824Y 223

8.3247)0(453.123)0(736.424)0(805.86)24(485.3)24(319.17471.824Y 224

Page 59: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Crystal Ball (CB) Predictor

• CB Predictor is an add-in that simplifies the process of performing time series analysis in Excel.

• A trial version of CB Predictor is available on the CD-ROM accompanying this book.

• For more information on CB Predictor see:

http://www.decisioneering.com

Page 60: Time Series Analysis for e-business. “Forecasting is very dangerous, especially about the future.” --- Samuel Goldwyn

Combining Forecasts• It is also possible to combine forecasts to create a composite forecast.• Suppose we used three different forecasting methods on a given data

set.

• Denote the predicted value of time period t using each method as follows:

tttFFF 321 and ,,

• We could create a composite forecast as follows: Y F F Ft b b b b

t t t 0 1 1 2 2 3 3