Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2012 Pearson Education. All rights reserved. 20-1 Copyright © 2012 Pearson Education. All rights reserved. Chapter 20 Time Series Analysis.

Similar presentations


Presentation on theme: "Copyright © 2012 Pearson Education. All rights reserved. 20-1 Copyright © 2012 Pearson Education. All rights reserved. Chapter 20 Time Series Analysis."— Presentation transcript:

1 Copyright © 2012 Pearson Education. All rights reserved. 20-1 Copyright © 2012 Pearson Education. All rights reserved. Chapter 20 Time Series Analysis

2 Copyright © 2012 Pearson Education. All rights reserved. 20-2 20.1 What is a Time Series? Whenever data is recorded sequentially over time and Time is considered to be an important aspect, we have a time series. Most time series are equally spaced at roughly regular intervals, such as monthly, quarterly, or annually. The objective of most time series analyses is to provide forecasts of future values of the time series.

3 Copyright © 2012 Pearson Education. All rights reserved. 20-3 20.2 Components of a Time Series A time series consists of four components: Trend component (T) Seasonal component (S) Cyclical component (C) Irregular component (I) A time series may exhibit none of these components or maybe just one or two.

4 Copyright © 2012 Pearson Education. All rights reserved. 20-4 20.2 Components of a Time Series The Trend Component The overall pattern in the plot of the time series is called the trend component. If a series shows no particular trend over time and has a relatively consistent mean, it is said to be stationary in the mean. Most time series have an increasing (see figure) or decreasing trend with other fluctuations around the trend.

5 Copyright © 2012 Pearson Education. All rights reserved. 20-5 20.2 Components of a Time Series The Seasonal Component The seasonal component of a time series is the part of the variation that fluctuates in a way that is roughly stable over time with respect to timing, direction, and magnitude. Note that the first point in each set of four points is consistently higher in the time series plot above.

6 Copyright © 2012 Pearson Education. All rights reserved. 20-6 20.2 Components of a Time Series The Seasonal Component A deseasonalized, or seasonally adjusted series is one from which the seasonal component has been removed. The time between peaks of a seasonal component is referred to as the period.

7 Copyright © 2012 Pearson Education. All rights reserved. 20-7 20.2 Components of a Time Series Cyclical Component Regular cycles in the data with periods longer than one year are referred to as cyclical components. When a cyclical component can be related to a predictable phenomenon, then it can be modeled based on some regular behavior and added to whatever model is being built for the time series.

8 Copyright © 2012 Pearson Education. All rights reserved. 20-8 20.2 Components of a Time Series Irregular Component In time series modeling, the residuals – the part of the data not fit by the model – are call the irregular component. Typically the variability of the irregular component is of interest – whether the variability changes over time or whether there are any outliers or spikes that may deserve special attention. A time series that has a relatively constant variance is said to be stationary in the variance.

9 Copyright © 2012 Pearson Education. All rights reserved. 20-9 20.2 Components of a Time Series Modeling Time Series Methods for forecasting a time series fall into two general classes: smoothing methods and regression-based modeling methods. Although the smoothing methods do not explicitly use the time series components, it is a good idea to keep them in mind. The regression models explicitly estimate the components as a basis for building models.

10 Copyright © 2012 Pearson Education. All rights reserved. 20-10 20.2 Components of a Time Series Example: Labor and Capital Output Data from the U.S. Bureau of Labor gives Output/hr Labor and Output/unit Capital. Analyze the time series plot below. Describe the Trend component. Is there evidence of a Seasonal component? Is there evidence of a cyclic component?

11 Copyright © 2012 Pearson Education. All rights reserved. 20-11 20.2 Components of a Time Series Example: Labor and Capital Output Data from the U.S. Bureau of Labor gives Output/hr Labor and Output/unit Capital. Analyze the time series plot below. Describe the Trend component. Horizontal. Is there evidence of a Seasonal component? No strong evidence of a Seasonal component. Is there evidence of a cyclic component? Yes, there is evidence of a cyclic component.

12 Copyright © 2012 Pearson Education. All rights reserved. 20-12 20.3 Smoothing Methods Most time series contain some random fluctuations that vary up and down rapidly that are of no help in forecasting. To forecast the value of a time series, we want to identify the underlying, consistent behavior of the series. The goal in smoothing is to “smooth away” the rapid fluctuations and capture the underlying behavior. Often, recent behavior is a good indicator of behavior in the near future. Smoothing out fluctuations is generally accomplished by averaging adjacent values in the series.

13 Copyright © 2012 Pearson Education. All rights reserved. 20-13 20.3 Smoothing Methods Consider the plot of a time series for the closing price of a stock over the course of a year. Note that there are random fluctuations but that an underlying pattern of closing prices is discernable.

14 Copyright © 2012 Pearson Education. All rights reserved. 20-14 20.3 Smoothing Methods Simple Moving Average Methods The Moving Average replaces each value in a time series by an average of the adjacent values. The number of values used to construct each average is called the length ( L ) of the moving average. A moving average of length L, denoted MA ( L ), simply uses the mean of the previous L actual values as the fitted value at each time.

15 Copyright © 2012 Pearson Education. All rights reserved. 20-15 20.3 Smoothing Methods Simple Moving Average Methods Calculate moving averages of length 5, MA (5), and 15, MA (15), for the closing price of the stock shown in the table. The forecasted price of the stock, MA (5), for the 5 th and 6 th day in the series is shown below. The last two columns in the table show the complete list of forecasted values.

16 Copyright © 2012 Pearson Education. All rights reserved. 20-16 20.3 Smoothing Methods Simple Moving Average Methods The forecasted values for MA (5) (blue) and MA (15) (brown) are plotted below. Note that the longer moving average is smoother but reacts to rapid changes in the data more slowly.

17 Copyright © 2012 Pearson Education. All rights reserved. 20-17 20.3 Smoothing Methods Simple Moving Average Methods To obtain a forecast for a new time point, analysts use the last average in the series. This is the simple moving average forecast. It is the simplest forecast, called the naïve forecast, and it can only forecast one time period into the future. Moving averages are often used as summaries of how a time series is changing. Outliers tend to affect means and may distort the moving average summary.

18 Copyright © 2012 Pearson Education. All rights reserved. 20-18 20.3 Smoothing Methods Weighted Moving Averages A weight can be assigned to each value in a weighted averaging scheme according to how far it is before the current value. Each value is multiplied by a weight before summing, and the total is divided by the sum of the weights. Weighted moving averages form a very general class of smoothers. Two types of weighted moving average smoothers are commonly used on time series data: exponential smoothers and autoregressive moving averages.

19 Copyright © 2012 Pearson Education. All rights reserved. 20-19 20.3 Smoothing Methods Exponential Smoothing Methods Exponential smoothing is a weighted moving average with weights that decline exponentially into the past. This model is called the single-exponential smoothing model (SES). The weight, α, indicates the amount of weight given to the current value while 1 – α is the weight given to the historical data. All previous values are used in exponential smoothing with distant values getting increasingly smaller weight. This can be seen by expanding the equation above to obtain the equation below.

20 Copyright © 2012 Pearson Education. All rights reserved. 20-20 20.3 Smoothing Methods Exponential Smoothing Methods Below we see a plot of the closing price of a stock (data shown in earlier slide) with exponentially smoothed values using α = 0.75 (brown) and α = 0.10 (green). The curve using the larger weight follows the series closely while the curve using the smaller weight is smoother but doesn’t follow rapid changes well.

21 Copyright © 2012 Pearson Education. All rights reserved. 20-21 20.3 Smoothing Methods Example: Labor Data are given on the 2006 monthly prices of Apples and Gasoline. Find a 2-point moving average for Gasoline prices. Use it to predict the value for January 2007. MonthJanFebMarAprMayJunJulAugSepOctNovDec Apples0.9630.9770.9350.9581.0211.0531.1461.2351.2561.1381.0891.027 Gasoline2.3592.3542.4442.8012.9932.9633.0463.0332.6372.3192.2872.380

22 Copyright © 2012 Pearson Education. All rights reserved. 20-22 20.3 Smoothing Methods Example: Labor Data are given on the 2006 monthly prices of Apples and Gasoline. Find a 2-point moving average for Gasoline prices. Use it to predict the value for January 2007. MonthJanFebMarAprMayJunJulAugSepOctNovDec Apples0.9630.9770.9350.9581.0211.0531.1461.2351.2561.1381.0891.027 Gasoline2.3592.3542.4442.8012.9932.9633.0463.0332.6372.3192.2872.380 MA (2)*2.35652.3992.62252.8972.9783.4503.03952.8362.4782.3032.3335

23 Copyright © 2012 Pearson Education. All rights reserved. 20-23 20.4 Summarizing Forecast Error Recall that to obtain a forecast for a new time point, analysts use the last average in the series. We define the forecast error at any time t as: To consider the overall success of a model at forecasting for a time series we can use the mean squared error (MSE).

24 Copyright © 2012 Pearson Education. All rights reserved. 20-24 20.4 Summarizing Forecast Error The MSE penalizes large errors because the errors are squared, and it is not in the same units as the data. We address these issues by defining the mean absolute deviation ( MAD ). The MAD is in the same units but its values will be rescaled if the measurements are rescaled.

25 Copyright © 2012 Pearson Education. All rights reserved. 20-25 20.4 Summarizing Forecast Error The most common approach to measuring forecast error compares the absolute errors to the magnitude of the estimated quantity. This leads to what is called the mean absolute percentage error (MAPE). Since the MAPE is a percent, it is independent of the units of the y variable.

26 Copyright © 2012 Pearson Education. All rights reserved. 20-26 20.5 Autoregressive Models Simple moving averages and exponential smoothing methods are good choices for series with no regular long-term patterns. If such patterns are present, we may want to choose weights that facilitate modeling that structure. To find the weights, we can use the methods of multiple regression. We do so by shifting the data by a few time periods, a process know as lagging which leads to the lagged variables. A regression is fit to the data to predict a time series from its lagged variables.

27 Copyright © 2012 Pearson Education. All rights reserved. 20-27 20.5 Autoregressive Models The table shows the data for the closing price of a stock together with four lagged variables. If we fit a regression to predict a time series from its lag1 and lag2 versions, each predicted value is just the sum of the two lagged values weighted by the fitted coefficients b 1 and b 2.

28 Copyright © 2012 Pearson Education. All rights reserved. 20-28 20.5 Autoregressive Models The correlation between a series and a (lagged) version of the same series that is offset by a fixed number of time periods is called autocorrelation. The table shows some autocorrelations for the previous example.

29 Copyright © 2012 Pearson Education. All rights reserved. 20-29 20.5 Autoregressive Models A regression model that is based on an average of prior values in the series weighted according to a regression on lagged version of the series is called an autoregressive model. A pth-order autoregressive model has the form

30 Copyright © 2012 Pearson Education. All rights reserved. 20-30 20.5 Autoregressive Models For the closing price of a stock data and its four lag variables in a previous slide, we find the coefficients for a fourth-order autoregressive model. Because a fourth-order model is created, the model can be used to predict four time periods into the future.

31 Copyright © 2012 Pearson Education. All rights reserved. 20-31 20.5 Autoregressive Models From the table in the previous slide, we obtain the following fourth-order autoregressive model. We see that this model puts the greatest emphasis on the lag1 variable based on the relative sizes of the coefficients. A plot of this model with the time series data is provided.

32 Copyright © 2012 Pearson Education. All rights reserved. 20-32 20.5 Autoregressive Models Random Walks The naïve forecast model is sometimes called a random walk because each new value can be thought of as a random step away from the previous value. Time series modeled by a random walk can have rapid and sudden changes in direction, but they also may have long periods of runs up or down that can be mistaken for cycles.

33 Copyright © 2012 Pearson Education. All rights reserved. 20-33 20.5 Autoregressive Models Example: Recall Labor Data are given on the 2006 monthly prices of Apples and Gasoline. Find the lag2 version of Gasoline prices. Use it to predict the value for January 2007. MonthJanFebMarAprMayJunJulAugSepOctNovDec Apples0.9630.9770.9350.9581.0211.0531.1461.2351.2561.1381.0891.027 Gasoline2.3592.3542.4442.8012.9932.9633.0463.0332.6372.3192.2872.380

34 Copyright © 2012 Pearson Education. All rights reserved. 20-34 20.5 Autoregressive Models Example: Recall Labor Data are given on the 2006 monthly prices of Apples and Gasoline. Find the lag2 version of Gasoline prices. Simply offset the prices by two months. Use it to predict the value for January 2007. The predicted value for 2007 would be the price from November, $2.287 MonthJanFebMarAprMayJunJulAugSepOctNovDec Apples0.9630.9770.9350.9581.0211.0531.1461.2351.2561.1381.0891.027 Gasoline2.3592.3542.4442.8012.9932.9633.0463.0332.6372.3192.2872.380 Lag2**2.3592.3542.4442.8012.9932.9633.0463.0332.6372.319

35 Copyright © 2012 Pearson Education. All rights reserved. 20-35 20.5 Autoregressive Models Example: (continued) Labor Data are given on the 2006 monthly prices of Apples and Gasoline. A second-order autoregressive model is created and output given below. Dependent variable is: Gas R squared = 82.2% R squared (adjusted) = 77.1% s = 0.1498 with 10 - 3 = 7 degrees of freedom Variable Coefficient SE(Coeff) t-ratio P-value Intercept 1.28207 0.4644 2.76 0.0281 Lag1 1.31432 0.2383 5.51 0.0009 Lag2 –0.788250 0.2457 –3.21 0.0149 Predict the value for January 2007.

36 Copyright © 2012 Pearson Education. All rights reserved. 20-36 20.5 Autoregressive Models Example: (continued) Labor Data are given on the 2006 monthly prices of Apples and Gasoline. A second-order autoregressive model is created and output given below. Dependent variable is: Gas R squared = 82.2% R squared (adjusted) = 77.1% s = 0.1498 with 10 - 3 = 7 degrees of freedom Variable Coefficient SE(Coeff) t-ratio P-value Intercept 1.28207 0.4644 2.76 0.0281 Lag1 1.31432 0.2383 5.51 0.0009 Lag2 – 0.788250 0.2457 –3.21 0.0149 Predict the value for January 2007.

37 Copyright © 2012 Pearson Education. All rights reserved. 20-37 20.6 Multiple Regression-based Models Recall that some time series have identifiable components: a trend, a seasonal component, and possibly a cyclical component. The models studied so far do not attempt to model these components directly. Modeling the components directly can have two distinct advantages. 1)The ability to forecast beyond the immediate next time period. 2)The ability to understand the components themselves and reach a deeper understanding of the time series.

38 Copyright © 2012 Pearson Education. All rights reserved. 20-38 20.6 Multiple Regression-based Models Modeling the Trend Component When a time series has a linear trend, it is natural to model it with a linear regression of y t on Time. The residuals would then be a detrended version of the time series. Attractive feature of a regression-based model: The coefficient of Time can be interpreted directly as the change in y per time unit.

39 Copyright © 2012 Pearson Education. All rights reserved. 20-39 20.6 Multiple Regression-based Models Modeling the Trend Component When the time series doesn’t have a linear trend, we can often improve the linearity of the relationship with a re- expression of the data. The re-expression most often used with time series is the logarithm. The interpretation of the trend coefficient is different representing the percent growth or decline per time unit.

40 Copyright © 2012 Pearson Education. All rights reserved. 20-40 20.6 Multiple Regression-based Models Modeling the Seasonal Component Note that the plot of the logarithmically re-expressed quarterly sales below shows a strong seasonal component with a spike every fourth quarter.

41 Copyright © 2012 Pearson Education. All rights reserved. 20-41 20.6 Multiple Regression-based Models Modeling the Seasonal Component Introduce an indicator or dummy variable for each season (Chapter 19). We define Q 1 = 1 in quarter in 1 and 0, otherwise Q 2 = 1 in quarter in 2 and 0, otherwise, and Q 3 = 1 in quarter in 3 and 0, otherwise. The intercept coefficient will estimate a level for the period “left out”, and the coefficient of each dummy variable estimates the shift up or down in the series relative to that base level.

42 Copyright © 2012 Pearson Education. All rights reserved. 20-42 20.6 Multiple Regression-based Models Additive and Multiplicative Models Adding dummy variables to the regression of a time series on Time turns what was a simple one-predictor regression into a multiple regression. If we model the original values, we have added the seasonal component, S, (in the form of dummy variables) to the trend component, T, (in the form of an intercept coefficient and a regression with the Time variable as a predictor). We can write This is an additive model because the components are added in the model.

43 Copyright © 2012 Pearson Education. All rights reserved. 20-43 20.6 Multiple Regression-based Models Additive and Multiplicative Models After re-expressing a time series using the logarithm, we can still find a multiple regression. Because we are modeling the logarithm of the response variable, the model components are multiplied and we have a multiplicative model Although the terms in a multiplicative model are multiplied, we always fit the multiplicative model by taking logarithms, changing the form to an additive model that can be fit by multiple regression.

44 Copyright © 2012 Pearson Education. All rights reserved. 20-44 20.6 Multiple Regression-based Models Cyclical and Irregular Components Time series models that are additive over their trend component, seasonal component, cyclical component, and irregular components may be written Time series models that are multiplicative over their trend component, seasonal component, cyclical component, and irregular components may be written

45 Copyright © 2012 Pearson Education. All rights reserved. 20-45 20.6 Multiple Regression-based Models Cyclical and Irregular Components Whenever there is a business, economic, or physical cycle whose cause is understood and can be relied upon, we look for an external or exogenous variable to model the cycle. The regression models we’ve been considering can accommodate such additional predictors naturally.

46 Copyright © 2012 Pearson Education. All rights reserved. 20-46 20.6 Multiple Regression-based Models Cyclical and Irregular Components The irregular components are the residuals – what is left over after we fit all the other components. The residuals should be examined to check any assumptions and also see if there might be other patterns apparent in the residuals that can be modeled. In time series models, we plot the residuals against Time.

47 Copyright © 2012 Pearson Education. All rights reserved. 20-47 20.6 Multiple Regression-based Models Cyclical and Irregular Components The figure shows the plot of the residuals of a multiplicative model for quarterly sales. We note that the fourth quarters in 2001 and 2007 stand out. This suggests that the seasonal model may need to be improved. Also, a possible cyclical pattern of about 4 years is apparent, which might be worth investigating to see if a component can be added to the model.

48 Copyright © 2012 Pearson Education. All rights reserved. 20-48 20.6 Multiple Regression-based Models Forecasting with Regression-based Models Regression models are easy to use for forecasting, and they can be used to forecast beyond the next time period. The uncertainty of the forecast grows the further we extrapolate. The seasonal component is the most reliable part of the regression model. The patterns seen in this component can probably be expected to continue into the future. The trend component is less reliable since the growth of real- world phenomena cannot be maintained indefinitely. The reliability of the cyclical component for forecasting must be based on one’s understanding of the underlying phenomena.

49 Copyright © 2012 Pearson Education. All rights reserved. 20-49 20.6 Multiple Regression-based Models Forecasting with Regression-based Models The table below compares the forecasts from four regression- based models for the quarterly sales of a business. The data (seen earlier in this chapter) was not linear, so it’s not surprising the two additive models underestimate. The multiplicative trend model without seasonal components doesn’t take into account that Q1 typically sees higher sales.

50 Copyright © 2012 Pearson Education. All rights reserved. 20-50 20.7 Choosing a Time Series Forecasting Method Simple moving averages demand the least data and can be applied to almost any time series. However: They forecast well only for the next time period. They are sensitive to spikes or outliers in the series. They don’t do well on series that have a strong trend.

51 Copyright © 2012 Pearson Education. All rights reserved. 20-51 20.7 Choosing a Time Series Forecasting Method Exponential smoothing methods have the advantage of controlling the relative importance of recent values relative to older ones. However: They forecast well only for the next time period. They are sensitive to spikes or outliers in the series. They don’t do well on series that have a strong trend.

52 Copyright © 2012 Pearson Education. All rights reserved. 20-52 20.7 Choosing a Time Series Forecasting Method Autoregressive moving average models use automatically determined weights to allow them to follow time series that have regular fluctuations. However: They forecast for a limited span, depending on the shortest lag in the model. They are sensitive to spikes or outliers in the series.

53 Copyright © 2012 Pearson Education. All rights reserved. 20-53 20.7 Choosing a Time Series Forecasting Method Regression-based models can incorporate exogenous variables to help model business cycles and other phenomena. They can also be used to forecast into the future. However: You must decide whether to fit an additive model or to re- express the series by logarithms and fit the resulting multiplicative model. These models are sensitive to outliers and failures of linearity. Seasonal effects must be consistent in magnitude during the time covered by the data. Forecasts depend on the continuation of the trend and seasonal patterns.

54 Copyright © 2012 Pearson Education. All rights reserved. 20-54 20.8 Interpreting Time Series Models: The Whole Foods Data Revisited Time series models based on regression encourage interpretation of the coefficients. The Whole Foods model is based on a strong seasonal component. But the model reveals a surprising seasonal spike in food sales, so let’s return to the data. It turns out that Whole Foods Market divides its financial year into three quarters of 12 weeks and one of 16 weeks. The spike is due entirely to this bookkeeping anomaly. The seasonal peaks are 16/12 = 1.33 times as big as the other quarters – almost exactly what the multiplicative model estimated them to be. This cautionary tale reminds us to interpret models only in the context of the data.

55 Copyright © 2012 Pearson Education. All rights reserved. 20-55 Don’t use a linear trend model to describe a nonlinear trend. Consider patterns in the scatter plot or residuals that may indicate the need to transform the data. Don’t use a trend model for short-term forecasting. Trend models are most effective for long-term forecasting, but be aware that of the errors inherent in long-term forecasting. Don’t use a moving average, or exponential smoothing, or an autoregressive model for long-term forecasting. Smoothing models are most effective for short-term forecasting because they require continuous updating. Don’t ignore autocorrelation if it is present. Look at correlations among the lagged versions of the time series.

56 Copyright © 2012 Pearson Education. All rights reserved. 20-56 What Have We Learned? Be able to recognize when data are in a time series. A time series consists of data recorded sequentially over time, usually at equally spaced intervals. Time series analyses often attempt to provide forecasts of future values of the series.

57 Copyright © 2012 Pearson Education. All rights reserved. 20-57 What Have We Learned? Recognize the four components of a time series. The Trend component measures the overall tendency of the series to increase or decrease. It is ordinarily estimated as the slope of a regression against Time. The Seasonal component measures regular, repeating fluctuations. Often these are due to seasons of the year, but the term applies to any such regular fluctuation. Seasonal components are often estimated by introducing indicator (dummy) variables in a regression model. The Cyclic component accounts for such things as long-term business cycles. The Irregular component is the random fluctuation around the time series model. It corresponds to the residuals from a time series model.

58 Copyright © 2012 Pearson Education. All rights reserved. 20-58 What Have We Learned? Use smoothing methods to see past random fluctuations (noise) in a time series to detect an underlying smoother pattern (signal). Simple Moving Average methods average a relatively small number of adjacent values to obtain a smooth value for each time period. Weighted Moving Average methods introduce weights. Because the weights can determine the behavior of the smoother, these are a very general class of time series methods. Exponential smoothing methods are weighted moving averages with weights that decline exponentially into the past. Autoregressive models use regression methods, predicting the time series from versions of the same series offset, or lagged, in time. The result is a weighted moving average method in which the weights are estimated from the data.

59 Copyright © 2012 Pearson Education. All rights reserved. 20-59 What Have We Learned? Estimate and report forecast error with statistics such as MSE, MAD, and MAPE.

60 Copyright © 2012 Pearson Education. All rights reserved. 20-60 What Have We Learned? Use multiple regression methods to model a structured time series, using Time, indicator variables for the Seasonal component, and exogenous variables that might account for the Cyclic component. Multiple regression models have the advantage that they can provide forecasts farther into the future. Additive Models estimate the components using multiple regression methods to find a model in which the estimates are added to yield the predicted values. Multiplicative models for a time series model the series as a product of its components. Multiplicative models are ordinarily estimated by taking the logarithm of the time series values and then using multiple regression as for additive models.


Download ppt "Copyright © 2012 Pearson Education. All rights reserved. 20-1 Copyright © 2012 Pearson Education. All rights reserved. Chapter 20 Time Series Analysis."

Similar presentations


Ads by Google