time series analysis. time-series numerical data obtained at regular time intervals the time...

56
Time Series Time Series Analysis Analysis

Upload: quintin-chipps

Post on 16-Dec-2015

224 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Time Series Time Series AnalysisAnalysis

Page 2: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Time-Series

• Numerical data obtained at regular time intervals

• The time intervals can be annually, quarterly, monthly, daily, hourly, etc.

Year Sales

1994 75.3

1995 74.2

1996 78.5

1997 79.9

1998 80.2

Page 3: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Time-Series Components

Time-Series

Cyclical

Random

Trend

Seasonal

Page 4: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Inherent in the collection of data taken over time is some form of

random variation. “Moving Average or Smoothing ” is a

technique used for reducing of or canceling the effect due to

random variation. “Smoothing” data removes random variation

and shows trends and cyclic components

Page 5: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Random or Irregular Random or Irregular ComponentComponent

• Nonsystematic, random, fluctuations

• Due to random variations of – Nature– Accidents

• Short duration and non-repeating

Page 6: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Upward trend

Trend ComponentTrend Component

• Overall upward or downward movement

• Data taken over a period of years

Sales

Time

Page 7: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Cyclical ComponentCyclical Component

• Upward or downward swings

• May vary in length

• Usually lasts 2 - 10 years

Sales 1 Cycle

Page 8: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Seasonal ComponentSeasonal Component

• Upward or downward swings

• Regular patterns

• Observed within 1 year

Sales

Time (Monthly or Quarterly)

WinterSpring

Summer

Fall

Winter

Page 9: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Taking averages is the simplest way to smooth data. Moving averages smooth out a data series and make it easier to identify the direction of the trend. Because past price data is used to form moving averages, they are considered lagging, or trend following, indicators. Moving averages will not predict a change in trend, but rather follow behind the current trend. Therefore, they are best suited for trend identification and trend following

purposes, not for prediction.

Page 10: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

A manager of a warehouse wants to know how much a typical supplier delivers in 1000 dollar units. He/she takes a sample of 12 suppliers, at random, obtaining the following results:

Page 11: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Supplier Amount Supplier Amount

1 9 7 11

2 8 8 7

3 9 9 13

4 12 10 9

5 9 11 11

6 12 12 10

Page 12: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 13: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 14: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The estimator with the smallest MSE is the best. It can be

shown mathematically that the estimator that minimizes the

MSE for a set of random data is the mean.

Page 15: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Next we will examine the mean to see how well it predicts net income over time?

The next table gives the income before taxes of APC manufacturer between 1985 and 1994.

Page 16: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 17: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Because of the limitations of the simple average we use Moving A verages which are developed based on an average of weighted observations. MA tends tosmooth out short-term irregularity in the data series. They are useful if the data series remains fairly steady over time.

Page 18: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving average depends on the span (period). If span is 6 months for monthly data then, the month’s predicted value is the average of the most recent 6 months. The average of Jan thru June will be used to predict July. The longer the span the better the smoothing.

Page 19: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving averages are one of the most popular and easy to use tools available to the technical analyst. They smooth a data series and make it easier to spot trends, something that is especially helpful in volatile markets.

Page 20: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Example of Quarterly Retail Sales with Seasonal Components

Quarterly with Seasonal Components

0

5

10

15

20

25

0 5 10 15 20 25 30 35

Time

Sale

s

Page 21: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Example of Quarterly Retail Sales with Seasonal Components

RemovedQuarterly without Seasonal Components

0

5

10

15

20

25

0 5 10 15 20 25 30 35

Time

Sa

les

Y(t)

Page 22: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Multiplicative Time-Series Model

• Used primarily for forecasting

• Observed value in time series is the product of components

• For annual data:

• For quarterly or monthly data:

Ti = Trend

Ci = Cyclical

Ii = Irregular

Si = Seasonal

i i i i iY T S C I

i i i iY TC I

Page 23: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The moving-average method provides an efficient mechanism for obtaining a value forforecasting stationary time series.

The method is effective when there is random demand and no seasonal fluctuations in the data. It is a popular technique for short-run forecasting by business forecasters.

Page 24: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving averages come in various forms, but their underlying purpose remains the same: to help technical traders track the trends of financial assets by smoothing out the day-to-day price fluctuations, or noise. By identifying trends, moving averages allow traders to make those trends work in their favor and increase the number of winning trades.

Page 25: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving Averages

• Example: Three-year moving average

– First average:

– Second average:

1 2 3(3)3

Y Y YMA

2 3 4(3)3

Y Y YMA

(continued)

Page 26: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving Average Example

Year Units Moving Ave

1994 2 NA

1995 5 3

1996 2 3

1997 2 3.67

1998 7 5

1999 6 NA

Mohammed is a building contractor who has constructed 24 single-family homes over a six-year period. Provide Mohammed with a three-year Moving Average Graph.

Page 27: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 28: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving Average Example Solution

Year Response Moving Ave

1994 2 NA

1995 5 3

1996 2 3

1997 2 3.67

1998 7 5

1999 6 NA94 95 96 97 98 99

8

6

4

2

0

SalesL = 3

No MA for the first and last (L-1)/2 years

Page 29: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 30: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

This simple illustration highlights the fact that all moving averages are lagging indicators and will always be "behind" the price of stock. If the close prices were rising, the SMA would most likely be below. Because moving averages are lagging indicators, they fit in the category of trend following indicators. When prices are trending, moving averages work well. However, when prices are not trending, moving averages can give misleading

signals.

Page 31: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

In order to reduce the lag in simple moving averages, technicians often use exponential moving averages (also called exponentially weighted moving averages). EMA's reduce the lag by applying more weight to recent prices relative to older prices.

Page 32: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Exponential Smoothing

• Weighted moving averageMost recent observation weighted most

• Used for smoothing and short term forecasting

• Weights are:– Subjectively chosen– Ranges from 0 to 1

Page 33: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Exponential Weight: Example

Year Response Smoothing Value, Ei Forecast(W = .2, (1-W)=.8)

1994 2 2 NA

1995 5 (.2)(5) + (.8)(2) = 2.6 2

1996 2 (.2)(2) + (.8)(2.6) = 2.48 2.6

1997 2 (.2)(2) + (.8)(2.48) = 2.384 2.48

1998 7 (.2)(7) + (.8)(2.384) = 3.307 2.384

1999 6 (.2)(6) + (.8)(3.307) = 3.846 3.307

1(1 )i i iE WY W E

Page 34: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Exponential Weight: Example Graph

94 95 96 97 98 99

8

6

4

2

0

Sales

Year

Data

Smoothed

Page 35: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Exponential Smoothing in Excel

• Use tools | data analysis | exponential smoothing– The damping factor is (1-W )

• Excel spreadsheet for the Exponential

Page 36: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 37: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 38: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Trend-Following Indicator

Moving averages smooth out a data series and make it easier to identify the direction of the trend. Because past price data is used to form moving averages, they are considered lagging, or trend following, indicators. Moving averages will not predict a change in trend, but rather follow behind the current trend. Therefore, they are best suited for trend identification and trend following purposes, not for prediction.

Page 39: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

When to Use

Because moving averages follow the trend, they work best when a security is trending and are ineffective when a security moves in a trading range. With this in mind, investors and traders should first identify securities that display some trending characteristics before attempting to analyze with moving averages.

Page 40: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

In its simplest form, a security's price can be doing only one of three things: trending up,

trending down or trading in a range. An uptrend is established when a security

forms a series of higher highs and higher lows. A downtrend is established when a security forms a series of lower lows and

lower highs. A trading range is established if a security cannot establish an uptrend or

downtrend.

Page 41: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Moving Averages

• Moving averages are used to smooth out short-term Moving averages are used to smooth out short-term fluctuations, thus highlighting longer-term trends or cycles.fluctuations, thus highlighting longer-term trends or cycles.

• moving average levels are interpreted as support in a rising market, or resistance in a falling market. One of the most-common and best-known trading strategies is this: "Buy at the support level and sell at the resistance level."

• Typically, upward momentum is confirmed when a short-term average (e.g.15-day) crosses above a longer-term average (e.g. 50-day). Downward momentum is confirmed when a short-term average crosses below a long-term average

• If current prices (15-day SMA) are moving above longer term prices (50-day SMA), these are indicative of buying momentum. The reverse would be indicative of selling momentum.

Page 42: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Resistance Level

"Resistance Level" is just the opposite. Here, the strategy is to short sell the stock near the resistance level, monitor it closely, and buy it to cut loss if it breaks meaningfully higher than the resistance level. If the resistance level indeed prevents the stock price from going up and it starts to bounce back down,

Page 43: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The support level

Imagine on a given day, a stock is traded very heavily at a certain price level. Also imagine that many traders remember this price level because they bought or sold the stock at this level. Next, suppose that the stock price first moves up away from this level and, later on, the stock price trades back again to the earlier level. Traders who previously bought the stock and sold it for a profit would likely buy it again at this level. Those who previously sold the stock at this level and missed the recent run-up would have a chance to buy it back. Such buying activities usually slow down the drop and may reverse the momentum. We can then say that the stock price has hit some "support level," by which we suppose that it most likely will not quickly drop through it.

Page 44: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The Least Squares Linear Trend Model

Year Coded X Sales (Y)

95 0 2

96 1 5

97 2 2

98 3 2

99 4 7

00 5 6

0 1i iY b b X

Page 45: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 46: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The Least Squares Linear Trend Model

(continued)

0 1ˆ 2.143 .743i i iY b b X X

Excel Output

CoefficientsIntercept 2.14285714X Variable 1 0.74285714

0

1

2

3

4

5

6

7

8

0 1 2 3 4 5 6X

Sale

s

Projected to year 2001

Page 47: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The Quadratic Trend Model

20 1 2i i iY b b X b X

Year Coded X Sales (Y)

95 0 2

96 1 5

97 2 2

98 3 2

99 4 7

00 5 6

Page 48: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 49: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,
Page 50: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

2 20 1 2

ˆ 2.857 .33 .214i i i i iY b b X b X X X

The Quadratic Trend Model(continued)

CoefficientsIntercept 2.85714286X Variable 1 -0.3285714X Variable 2 0.21428571

Excel Output

0

1

2

3

4

5

6

7

8

0 1 2 3 4 5 6 X

Sale

s Projected to year 2001

Page 51: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

The Exponential Trend Model

CoefficientsIntercept 0.33583795X Variable 10.08068544

0 1ˆ iXiY b b or

Excel Output of Values in logs

ˆ (2.17)(1.2) iXiY

antilog(.33583795) = 2.17antilog(.08068544) = 1.2

0 1 1ˆlog log logiY b X b

Year Coded X Sales (Y)

95 0 2

96 1 5

97 2 2

98 3 2

99 4 7

00 5 6

Page 52: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Model Selection Using Differences

• Use a linear trend model if the first differences are more or less constant

• Use a quadratic trend model if the second differences are more or less constant

2 1 3 2 1n nY Y Y Y Y Y

3 2 2 1 1 1 2n n n nY Y Y Y Y Y Y Y

Page 53: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Model Selection Using Differences

3 2 12 1

1 2 1

100% 100% 100%n n

n

Y Y Y YY Y

Y Y Y

• Use an exponential trend model if the percentage differences are more or less constant

(continued)

Page 54: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Selecting A Forecasting Model

• Perform a residual analysis– Look for pattern or direction

• Measure sum of square error - SSE (residual errors)

• Use simplest model

Page 55: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Residual Analysis

Random errors

Trend not accounted for

Cyclical effects not accounted for

Seasonal effects not accounted for

T T

T T

e e

e e

0 0

0 0

Page 56: Time Series Analysis. Time-Series Numerical data obtained at regular time intervals The time intervals can be annually, quarterly, monthly, daily, hourly,

Measuring Errors

• Choose a model that gives the smallest measuring errors

• Sum square error (SSE)–

– Sensitive to outliers

2

1

ˆn

i ii

SSE Y Y