Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form:...

24
Modeling Time Series Data Module 5 S T y *

Transcript of Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form:...

Page 1: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Modeling Time Series Data

Module 5

STy *

Page 2: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

A Composite Model

We can fit a composite model of the form:

Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Page 3: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Trend

A linear model captures the general upward (or downward) trend with steady growth.

Trend is the long term level and the pattern of change in the dependent variable. It is estimated as a simple function of the period number (time). Linear regression or method of least squares is used to estimate the trend.

Page 4: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Seasonality

Seasonality captures regular, predictable deviations from the trend. Typical seasons are quarters, weeks, or days.

Seasonality is a cycle with a period of exactly one year. We estimate it as a proportion of trend for each season. Data must

be available on seasonal basis.

Time series decomposition is a method to estimate seasonal component.

Page 5: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Cyclicality

Cyclicality captures the effects of long-term macroeconomic boom-bust cycles. It is often difficult to get enough data to measure accurately.

Page 6: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Composite Model

Any residual deviations are attributed to random error.

Page 7: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Time Series Decomposition

• Start with raw data (y)• Estimate Seasonal Indices

– Compute base trend using centered moving averages (t’)– Estimate seasonal ratios (y/t’)– Average seasonal ratios to get raw seasonal indices– Normalize seasonal indices (s)

• De-seasonalize the raw data (y/s)• Estimate the trend equation using de-seasonalized data

(t)• Forecast y’ = t * s• Calculate error = y – (t*s)

Page 8: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: Modeling Trend and Seasonality

Toys R Us Revenue (millions $)

Per Year Qtr Revenue

1 1992 1 1026.00

2 1992 2 1056.00

3 1992 3 1182.00

4 1992 4 2861.00

5 1993 1 1172.00

6 1993 2 1249.00

7 1993 3 1346.00

8 1993 4 3402.00

9 1994 1 1286.00

10 1994 2 1317.00

11 1994 3 1449.00

12 1994 4 3893.00

13 1995 1 1462.00

14 1995 2 1452.00

15 1995 3 1631.00

16 1995 4 4200.00

17 1996 1 1776.25

18 1996 2 1808.25

19 1996 3 1941.75

20 1996 4 4128.75

Page 9: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: Computing Moving Averages

Per Year Qtr Revenue Moving Avg

1 1992 1 1026.00  

2 1992 2 1056.00  

3 1992 3 1182.00 1531.3

4 1992 4 2861.00 1567.8

5 1993 1 1172.00 1616.0

6 1993 2 1249.00 1657.0

7 1993 3 1346.00 1792.3

8 1993 4 3402.00 1820.8

9 1994 1 1286.00 1837.8

10 1994 2 1317.00 1863.5

11 1994 3 1449.00 1986.3

12 1994 4 3893.00 2030.3

13 1995 1 1462.00 2064.0

14 1995 2 1452.00 2109.5

15 1995 3 1631.00 2186.3

16 1995 4 4200.00 2264.8

17 1996 1 1776.25 2353.9

18 1996 2 1808.25 2431.6

19 1996 3 1941.75 2413.8

20 1996 4 4128.75  

Calculate Moving Average with span of 4

(1026 + 1056 + 1182 + 2861) 4 = 1531.3

Page 10: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Center Moving Average if using even number of data points

(1531.3 + 1567.8) 2 = 1549.5

Per Year Qtr Revenue Moving Avg Centered MA

1 1992 1 1026.00    

2 1992 2 1056.00    

3 1992 3 1182.00 1531.3 1549.5

4 1992 4 2861.00 1567.8 1591.9

5 1993 1 1172.00 1616.0 1636.5

6 1993 2 1249.00 1657.0 1724.6

7 1993 3 1346.00 1792.3 1806.5

8 1993 4 3402.00 1820.8 1829.3

9 1994 1 1286.00 1837.8 1850.6

10 1994 2 1317.00 1863.5 1924.9

11 1994 3 1449.00 1986.3 2008.3

12 1994 4 3893.00 2030.3 2047.1

13 1995 1 1462.00 2064.0 2086.8

14 1995 2 1452.00 2109.5 2147.9

15 1995 3 1631.00 2186.3 2225.5

16 1995 4 4200.00 2264.8 2309.3

17 1996 1 1776.25 2353.9 2392.7

18 1996 2 1808.25 2431.6 2422.7

19 1996 3 1941.75 2413.8  

20 1996 4 4128.75    

Example: Using centered moving averages to estimate base demand

Page 11: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: Computing Seasonal Ratios

Calculate the ratio of the revenue to the centered moving average

1182 1549.5 = .7628

Per Year Qtr RevenueMoving

AvgCentered

MA Ratio

1 1992 1 1026.00      

2 1992 2 1056.00      

3 1992 3 1182.00 1531.3 1549.5 0.7628

4 1992 4 2861.00 1567.8 1591.9 1.7973

5 1993 1 1172.00 1616.0 1636.5 0.7162

6 1993 2 1249.00 1657.0 1724.6 0.7242

7 1993 3 1346.00 1792.3 1806.5 0.7451

8 1993 4 3402.00 1820.8 1829.3 1.8598

9 1994 1 1286.00 1837.8 1850.6 0.6949

10 1994 2 1317.00 1863.5 1924.9 0.6842

11 1994 3 1449.00 1986.3 2008.3 0.7215

12 1994 4 3893.00 2030.3 2047.1 1.9017

13 1995 1 1462.00 2064.0 2086.8 0.7006

14 1995 2 1452.00 2109.5 2147.9 0.6760

15 1995 3 1631.00 2186.3 2225.5 0.7329

16 1995 4 4200.00 2264.8 2309.3 1.8187

17 1996 1 1776.25 2353.9 2392.7 0.7424

18 1996 2 1808.25 2431.6 2422.7 0.7464

19 1996 3 1941.75 2413.8    

20 1996 4 4128.75      

Page 12: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: Calculating raw Seasonal Indices

Calculate the average ratio for each season (quarter).

.7162 + .6949 + .7006 + .7424 4

Raw Seasonal Index = .7135

Per Year Qtr RevenueMoving

AvgCentered

MA RatioAvg

Ratio

1 1992 1 1026.00        

2 1992 2 1056.00        

3 1992 3 1182.00 1531.3 1549.5 0.7628  

4 1992 4 2861.00 1567.8 1591.9 1.7973  

5 1993 1 1172.00 1616.0 1636.5 0.7162 0.7135

6 1993 2 1249.00 1657.0 1724.6 0.7242 0.7077

7 1993 3 1346.00 1792.3 1806.5 0.7451 0.7406

8 1993 4 3402.00 1820.8 1829.3 1.8598 1.8444

9 1994 1 1286.00 1837.8 1850.6 0.6949  

10 1994 2 1317.00 1863.5 1924.9 0.6842  

11 1994 3 1449.00 1986.3 2008.3 0.7215  

12 1994 4 3893.00 2030.3 2047.1 1.9017  

13 1995 1 1462.00 2064.0 2086.8 0.7006  

14 1995 2 1452.00 2109.5 2147.9 0.6760  

15 1995 3 1631.00 2186.3 2225.5 0.7329  

16 1995 4 4200.00 2264.8 2309.3 1.8187  

17 1996 1 1776.25 2353.9 2392.7 0.7424  

18 1996 2 1808.25 2431.6 2422.7 0.7464  

19 1996 3 1941.75 2413.8      

20 1996 4 4128.75        

Page 13: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: Normalizing Seasonal Indices

Normalize to make sure Seasonal Indices average to 1.0 (or add up to 4 in this case)

.7135 ..7135+.7077+.7406+1.844

= .7124

Per Year Qtr RevenueMoving

AvgCentered

MA RatioAvg

Ratio SI

1 1992 1 1026.00         0.7124

2 1992 2 1056.00         0.7066

3 1992 3 1182.00 1531.3 1549.5 0.7628   0.7394

4 1992 4 2861.00 1567.8 1591.9 1.7973   1.8415

5 1993 1 1172.00 1616.0 1636.5 0.7162 0.7135 0.7124

6 1993 2 1249.00 1657.0 1724.6 0.7242 0.7077 0.7066

7 1993 3 1346.00 1792.3 1806.5 0.7451 0.7406 0.7394

8 1993 4 3402.00 1820.8 1829.3 1.8598 1.8444 1.8415

9 1994 1 1286.00 1837.8 1850.6 0.6949   0.7124

10 1994 2 1317.00 1863.5 1924.9 0.6842   0.7066

11 1994 3 1449.00 1986.3 2008.3 0.7215   0.7394

12 1994 4 3893.00 2030.3 2047.1 1.9017   1.8415

13 1995 1 1462.00 2064.0 2086.8 0.7006   0.7124

14 1995 2 1452.00 2109.5 2147.9 0.6760   0.7066

15 1995 3 1631.00 2186.3 2225.5 0.7329   0.7394

16 1995 4 4200.00 2264.8 2309.3 1.8187   1.8415

17 1996 1 1776.25 2353.9 2392.7 0.7424   0.7124

18 1996 2 1808.25 2431.6 2422.7 0.7464   0.7066

19 1996 3 1941.75 2413.8       0.7394

20 1996 4 4128.75         1.8415

Page 14: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing raw data

Deseasonalize observations.

= 1440.2

Per Year

Qtr Revenue

Moving Avg

Centered MA Ratio

Avg Ratio SI DeS

1 1992 1 1026.00         0.7124 1440.2

2 1992 2 1056.00         0.7066 1494.4

3 1992 3 1182.00 1531.3 1549.5 0.7628   0.7394 1598.5

4 1992 4 2861.00 1567.8 1591.9 1.7973   1.8415 1553.6

5 1993 1 1172.00 1616.0 1636.5 0.7162 0.7135 0.7124 1645.1

6 1993 2 1249.00 1657.0 1724.6 0.7242 0.7077 0.7066 1767.6

7 1993 3 1346.00 1792.3 1806.5 0.7451 0.7406 0.7394 1820.3

8 1993 4 3402.00 1820.8 1829.3 1.8598 1.8444 1.8415 1847.4

9 1994 1 1286.00 1837.8 1850.6 0.6949   0.7124 1805.1

10 1994 2 1317.00 1863.5 1924.9 0.6842   0.7066 1863.8

11 1994 3 1449.00 1986.3 2008.3 0.7215   0.7394 1959.6

12 1994 4 3893.00 2030.3 2047.1 1.9017   1.8415 2114.0

13 1995 1 1462.00 2064.0 2086.8 0.7006   0.7124 2052.2

14 1995 2 1452.00 2109.5 2147.9 0.6760   0.7066 2054.9

15 1995 3 1631.00 2186.3 2225.5 0.7329   0.7394 2205.7

16 1995 4 4200.00 2264.8 2309.3 1.8187   1.8415 2280.7

17 1996 1 1776.25 2353.9 2392.7 0.7424   0.7124 2493.3

18 1996 2 1808.25 2431.6 2422.7 0.7464   0.7066 2559.0

19 1996 3 1941.75 2413.8       0.7394 2626.0

20 1996 4 4128.75         1.8415 2242.0

1026 .7124

y’ = y/s

Page 15: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing

Fit a regression line to the deseasonalized observations – y’ (using time as the independent variable).

Page 16: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing

Use trend to make deseasonalized predictions - T

Per YearQtr Revenue

Moving Avg

Centered MA Ratio Avg Ratio SI DeS Forecast

1 1992 1 1026.00         0.7124 1440.2 1430.3

2 1992 2 1056.00         0.7066 1494.4 1487.3

3 1992 3 1182.00 1531.3 1549.5 0.7628   0.7394 1598.5 1544.2

4 1992 4 2861.00 1567.8 1591.9 1.7973   1.8415 1553.6 1601.1

5 1993 1 1172.00 1616.0 1636.5 0.7162 0.7135 0.7124 1645.1 1658.0

6 1993 2 1249.00 1657.0 1724.6 0.7242 0.7077 0.7066 1767.6 1715.0

7 1993 3 1346.00 1792.3 1806.5 0.7451 0.7406 0.7394 1820.3 1771.9

8 1993 4 3402.00 1820.8 1829.3 1.8598 1.8444 1.8415 1847.4 1828.8

9 1994 1 1286.00 1837.8 1850.6 0.6949   0.7124 1805.1 1885.8

10 1994 2 1317.00 1863.5 1924.9 0.6842   0.7066 1863.8 1942.7

11 1994 3 1449.00 1986.3 2008.3 0.7215   0.7394 1959.6 1999.6

12 1994 4 3893.00 2030.3 2047.1 1.9017   1.8415 2114.0 2056.6

13 1995 1 1462.00 2064.0 2086.8 0.7006   0.7124 2052.2 2113.5

14 1995 2 1452.00 2109.5 2147.9 0.6760   0.7066 2054.9 2170.4

15 1995 3 1631.00 2186.3 2225.5 0.7329   0.7394 2205.7 2227.4

16 1995 4 4200.00 2264.8 2309.3 1.8187   1.8415 2280.7 2284.3

17 1996 1 1776.25 2353.9 2392.7 0.7424   0.7124 2493.3 2341.2

18 1996 2 1808.25 2431.6 2422.7 0.7464   0.7066 2559.0 2398.2

19 1996 3 1941.75 2413.8       0.7394 2626.0 2455.1

20 1996 4 4128.75         1.8415 2242.0 2512.0

56.93 * (1) + 1373.4 =

1430.3

Page 17: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing

Per YearQtr Revenue

Moving Avg

Centered MA Ratio

Avg Ratio SI DeS

Forecast ReS

1 1992 1 1026.00         0.7124 1440.2 1430.3 1019.0

2 1992 2 1056.00         0.7066 1494.4 1487.3 1050.9

3 1992 3 1182.00 1531.3 1615.5 0.7317   0.7394 1598.5 1544.2 1141.8

4 1992 4 2861.00 1699.7 1699.7 1.6833   1.8415 1553.6 1601.1 2948.5

- - - - - - - - - - - -

13 1995 1 1462.00 1457.0 1486.0 0.9838   0.7124 2052.2 2113.5 1505.7

14 1995 2 1452.00 1515.0 1850.6 0.7846   0.7066 2054.9 2170.4 1533.7

15 1995 3 1631.00 2186.3 2225.5 0.7329   0.7394 2205.7 2227.4 1647.0

16 1995 4 4200.00 2264.8 2309.3 1.8187   1.8415 2280.7 2284.3 4206.6

17 1996 1 1776.25 2353.9 2392.7 0.7424   0.7124 2493.3 2341.2 1667.9

18 1996 2 1808.25 2431.6 2422.7 0.7464   0.7066 2559.0 2398.2 1694.6

19 1996 3 1941.75 2413.8       0.7394 2626.0 2455.1 1815.4

20 1996 4 4128.75         1.8415 2242.0 2512.0 4625.9

21 0.71241 2568.9 1830.2

22 0.70662 2625.9 1855.5

23 0.73944 2682.8 1983.8

24 1.84153 2739.7 5045.3

Reseasonalize predictions (T*S) to make forecasts into the future.

2568.9 * .71241 = 1830.2

Page 18: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing

Plot the forecasts – T*S

Page 19: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing

Per Year Qtr Revenue

Reseason-alized forecast Square Error

1 1992 1 1026 1018.983 97.00468

2 1992 2 1056 1050.927 51.54981

3 1992 3 1182 1141.832 2950.947

4 1992 4 2861 2948.503 2257.815

5 1993 1 1172 1181.217 167.3762

6 1993 2 1249 1211.841 2765.401

7 1993 3 1346 1310.219 2341.483

8 1993 4 3402 3367.862 343.6507

9 1994 1 1286 1343.45 6503.07

10 1994 2 1317 1372.755 6225.828

11 1994 3 1449 1478.607 1603.193

12 1994 4 3893 3787.221 3299.437

13 1995 1 1462 1505.684 3759.864

14 1995 2 1452 1533.669 13358.15

15 1995 3 1631 1646.995 467.8932

16 1995 4 4200 4206.581 12.7695

17 1996 1 1776.25 1667.917 23123.7

18 1996 2 1808.25 1694.584 25875.59

19 1996 3 1941.75 1815.382 29205.72

20 1996 4 4128.75 4625.94 72893.41

9865.2

(1026 – 1018.98)2 = 97.0

Average square error

As an alternative goodness of fit measure, calculate Root Mean Square Error.

RMSE = 9865.2 = 99.3

Page 20: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing with Statpro

Statpro can be used to calculate seasonal indices. Click on Statpro -> Forecast.

http://www.indiana.edu/~mgtsci/StatPro.html

Page 21: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing with Statpro

Select the dependent variable.

Page 22: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing with Statpro

Select quarterly data.

Page 23: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing with Statpro

Select a span of 4 and a moving average method of deseasonalizing.

Page 24: Modeling Time Series Data Module 5. A Composite Model We can fit a composite model of the form: Sales = (Trend) * (Seasonality) * (Cyclicality) * (Error)

Example: De-Seasonalizing with Statpro

Statpro generates the same values that we calculated manually.

(Statpro output)