Sei sulla pagina 1di 17

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

APS 425 Spring 2004

Time Series Analysis: Autocorrelation Instructor: G. William Schwert


585-275-2470 schwert@schwert.simon.rochester.edu

Topics
Causes of autocorrelation Diagnosing autocorrelation Modeling autocorrelation

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Autocorrelation
When the data used in regression model measure the same thing at different points in time, such as the price of Xerox stock, XRXt, it is not unusual for adjacent observations to be correlated with each other [APS_XRX.WF1] Corr(XRXt, XRXt-1) > 0, means that when the stock price in period t-1 is above the sample average, it is likely that the stock price in period t will also be above the sample average A graph of positively autocorrelated data shows smooth cycles, infrequently crossing the average

Diagnosing Autocorrelation in Eviews

Calculate autocorrelations from View menu

Graph data from View menu

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Autocorrelation: Xerox Stock Price, 1970-1999

Note: autocorrelations start at .96 and decay slowly to .59


graph shows slowly moving, persistent pattern

Autocorrelation: Why?
Autocorrelation happens for many reasons Information changes slowly through time, so the factors influencing a variable are likely to be similar in adjacent periods

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Example: Random Walk Model for Stock Prices


If returns to stocks, rt, are random through time (unpredictable), perhaps because the market processes information efficiently and incorporates it into prices immediately, Prices (or the logs of prices) will follow a random walk, since this periods (log) price, log(Pt), equals last periods (log) price, log(Pt-1), plus this periods random (continuously compounded) return:
rt = log(Pt) - log(Pt-1) = log(Pt / Pt-1) = log(1 + (Pt - Pt-1)/ Pt-1))

Example: Random Walk Model for Stock Prices


While the changes in (log) prices are random and unpredictable, the (log) prices in consecutive months contain much of the same information
The (log) price at time t is just the (log) price at time 0 plus the sum of all returns between 0 and t log(Pt) = rt + rt-1 + . . . + r1 + log(P0) So log(Pt) and log(Pt-1) share t-1 past returns, which means they will be highly correlated

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Autocorrelation: Xerox Stock Returns, 1970-1999

Note: autocorrelations for returns are much smaller and returns vary randomly around the mean

Correcting for Autocorrelation: ARIMA Models


A simple class of models called autoregressive (AR), integrated (I), moving average (MA) models are often used to represent autocorrelated series AR(1) model uses the last observation on the series to predict the current one: Yt = a + b1 Yt-1 + et AR(P) model uses the last P observations on the series to predict the current one: Yt = a + b1 Yt-1 + . . . + bP Yt-P + et

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

AR(P) Models in Eviews

AR(1) model for log of Xerox stock price by using the lagged dependent variable, log(XRXP(-1)), as the independent variable
Note that the AR(1) coefficient is close to 1

AR(P) Models in Eviews

AR(1) model for log of Xerox stock price by using the AR(1) specification for the errors
Note the only difference is the constant, which equals the sample mean of XRXP in this case and [sample mean (1 - .971) ] when the lagged dependent variable is used

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Residual Autocorrelations from AR(1) Model for Xerox Stock

Residuals are not autocorrelated, so we fixed the problem

Correcting for Autocorrelation: Differencing


A series is called integrated (the I in ARIMA) when the levels of the series seem to wander around with no tendency to return to any particular point (e.g., the mean), but the differences, Yt = (Yt - Yt-1), seem to be stationary When the AR(1) coefficient is essentially 1.0 (as in the stock price example), this says you should be analyzing the changes in prices (or returns), not the levels Take first differences of the data, then estimate an ARMA model for the changes

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Example: Consumer Price Index


Workfile A425_CPI.WF1 contains the Consumer Price Index for All Urban Consumers both seasonally adjusted (CPISA) and not seasonally adjusted (CPINSA) from the Bureau of Labor Statistics monthly from 1947 through September 2002 Seasonal adjustment is a complicated filter that is intended to remove seasonal patterns from data (well look at whether it is successful here later) Looks like exponential growth => use log transformation

Logs of Consumer Price Index


LCPINSA = log(CPINSA) This plot looks more linear, so log transformation works pretty well But there is still a pronounced upward trend Try a regression against a time trend, time = @trend

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Trend Model for Log of Consumer Price Index

Model looks great??? R2 = 96% Coefficient of time = 0.0036 .36% inflation per month, about 4.3% per year But, lots of serial correlation in the residuals Durbin-Watson should be close to 2.0, not 0.0

Trend Model for Log of Consumer Price Index


Durbin-Watson if approximately 2 [ 1 auto(1)] where auto(1) is the first autocorrelation of the residuals So DW is between 0 and 4, with 2 being a good value Just as easy to look at the residual autocorrelations at all lags (allows you to see patterns beyond lag 1) Usually a good idea to look at multiples of the seasonal period In this case, with monthly data, we use 24 lags Note that the residual autocorrelations are large out to lag 24

(c) Prof. G. William Schwert, 2001-2004

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Inflation = Differences of Log of Consumer Price Index


Another way to eliminate trends is to look at changes of the variable In this case, the first difference of the logs of the CPI is the inflation rate

Autocorrelations of Inflation
Autocorrelations are much smaller, but still decay very slowly Note that differencing the time trend model
[LCPINSAt = a + b1 TIMEt + et ] INFLNSAt = a + b1 TIMEt + et - a - b1 TIMEt-1 - et-1 = b1 + et - et-1

since TIMEt - TIMEt-1 = 1 Therefore, the constant in the first differences equation (the average inflation rate) is the same as the slope coefficient in the time trend model for the log of the CPI

(c) Prof. G. William Schwert, 2001-2004

10

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Autocorrelations of Inflation: Try an AR(1) Model for Inflation

AR coefficient, 0.46, is pretty big (t-stat=8.57) Note R2 is much smaller than for time trend model it is in fact the square of the autoregressive coefficient, .462 This is NOT a problem, since the dependent variable is different logs of CPI for trend model and differences here The SE of regression is comparable, and smaller here (0.003402)

Diagnostics for AR(1) Model for Inflation


While the residual autocorrelations are much better than for the trend model, they still suggest that the AR(1) is not enough We will try an AR(4) model, just to see what happens

(c) Prof. G. William Schwert, 2001-2004

11

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

AR(4) Model for Inflation

AR(4) Model for Inflation: Interpretation


AR coefficients are all small and positive and seem to be decaying slowly This suggests a moving average (MA) part to the model MA models are like AR models, except that we used lagged errors instead of lagged values of the variable e.g., MA(1) model uses the last error to predict the current one: Yt = a + et + c1 et-1 MA(Q) model uses the last Q errors to predict the current one: Yt = a + et + c1 et-1 + . . . + cQ et-Q

(c) Prof. G. William Schwert, 2001-2004

12

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Try an MA(4) Model for Inflation

MA coefficients are all small and positive and seem to be decaying slowly This suggests that maybe we need both an AR and an MA part to the model => try ARMA(1,1) for inflation

Try an ARMA(1,1) Model for Inflation

This is the best yet AR coefficient is close to one, so we will also try differencing the inflation rate and then estimating an MA(1) model

(c) Prof. G. William Schwert, 2001-2004

13

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

ARMA(1,1) Model for Inflation: Diagnostics


Residual autocorrelations are pretty small now

ARIMA(0,1,1) Model for Inflation

D(INFLNSA) = INFLNSAt INFLNSAt-1

This simple model is virtually the same as the ARMA(1,1) model earlier, because we are constraining the AR coefficient to equal 1 (and it was .96)

(c) Prof. G. William Schwert, 2001-2004

14

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Estimating ARIMA Models in Eviews


The function d(gdp,0,4) specifies zero ordinary differencing with a seasonal difference at lag 4, or GDP-GDP(-4). If you need to work in logs, you can also use the dlog operator, which returns differences in the log values. For example, dlog(gdp) specifies the first difference of log(GDP) or log(GDP)log(GDP(-1)). You may also specify the difference and log options at seasonal frequencies as described for the simple d operator, dlog(x,n,s).

Estimating ARIMA models in Eviews


There are two ways to estimate integrated models in Eviews. First, you may generate a new series containing the differenced data, and then estimate an ARMA model using the new data. For example, to estimate a Box-Jenkins ARIMA(1, 1, 1) model for M1, you can enter: series dm1 = d(m1) ls dm1 c ar(1) ma(1) Alternatively, you may include the difference operator d directly in the estimation specification. For example, the same ARIMA(1,1,1) model can be estimated by the one-line command ls d(m1) c ar(1) ma(1)

(c) Prof. G. William Schwert, 2001-2004

15

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Estimating ARIMA Models in Eviews


The latter method should generally be preferred for an important reason: If you define a new variable, such as DM1 above, and use it in your estimation procedure, then when you forecast from the estimated model, Eviews will make forecasts of the dependent variable DM1. That is, you will get a forecast of the differenced series. If you are really interested in forecasts of the level variable, in this case M1, you will have to manually transform the forecasted value and adjust the computed standard errors accordingly. Moreover, if any other transformation or lags of M1 are included as regressors, Eviews will not know that they are related to DM1. If, however, you specify the model using the difference operator expression for the dependent variable, d(m1), the forecasting procedure will provide you with the option of forecasting the level variable, in this case M1.

Estimating ARIMA Models in Eviews


The difference operator may also be used in specifying independent variables and can be used in equations without ARMA terms. Simply include them in the list of regressors in addition to the endogenous variables. For example, d(cs,2) c d(gdp,2) d(gdp(-1),2) d(gdp(-2),2) time is a valid specification that employs the difference operator on both the left-hand and right-hand sides of the equation.

(c) Prof. G. William Schwert, 2001-2004

16

Time Series - Autocorrelation

APS 425 - Advanced Managerial Data Analysis

Links
Xerox Stock Price dataset:
http://schwert.simon.rochester.edu/A425/A425_xrx.wf1

CPI dataset:
http://schwert.simon.rochester.edu/A425/A425_cpi.wf1

Return to APS 425 Home Page:


http://schwert.simon.rochester.edu/A425/A425main.htm

(c) Prof. G. William Schwert, 2001-2004

17

Potrebbero piacerti anche