180 likes | 335 Vues
Lecture 7: Forecasting: Putting it ALL together. The full model. The model with seasonality, quadratic trend, and ARMA components can be written: Ummmm, say what???? The autoregressive components allow us to control for the fact that data is directly related to itself over time.
E N D
The full model • The model with seasonality, quadratic trend, and ARMA components can be written: • Ummmm, say what???? • The autoregressive components allow us to control for the fact that data is directly related to itself over time. • The moving average components, which are often less important, can be used in instances where past errors are expected to be useful in forecasting.
Model selection • Autocorrelation (AC) can be used to choose a model. The autocorrelations measure any correlation or persistence. For ARMA(p,q) models, autocorrelations begin behaving like an AR(p) process after lag q. • Partial autocorrelations (PAC) only analyze direct correlations. For ARMA(p,q) processes, PACs begin behaving like an MA(q) process after lag p. • For AR(p) process, the autocorrelation is never theoretically zero, but PAC cuts off after lag p. • For MA(q) process, the PAC is never theoretically zero, but AC cuts off after lag q.
Model selection • An important statistic that can used in choosing a model is the Schwarz Bayesian Information Criteria. It rewards models that reduce the sum of squared errors, while penalizing models with too many regressors. • SIC=log(SSE/T)+(k/T)log(T), where k is the number of regressors. • The first part is our reward for reducing the sum of squared errors. The second part is our penalty for adding regressors. We prefer smaller numbers to larger number (-17 is smaller than -10).
Important commands in EViews • ar(1): Includes a single autoregressive lag • ar(2): Includes a second autoregressive lag • Note, if you include only ar(2), EViews will not include a first order autoregressive lag • ma(1): Includes a first order moving average term. This is not the same as forecasting using an average of recent values
Selecting an appropriate time series model, concluded • Determine if trend/seasonality is important • If it is, include it in your model • Estimate the model with necessary trend/seasonal components. Look at the correlogram of the residuals: • From the equation dialogue box: • View => Residual Tests => Correlogram Q-statistics • If ACs decay slowly with abrupt cutoff in PAC, this is indicative of AR components. If the PAC doesn’t cutoff, you may need to include MA components as well. • Re-estimate the full model with trend/seasonality included with necessary ARMA components. You will likely have several models to choose from.
Selecting an appropriate model, cont. • After you estimate each model, record SIC/AIC values • Use the SIC/AIC values to select an appropriate model. • Finally, investigate the final set of residuals. There should be no correlation in your residuals. • Evidenced by individual correlation coefficients within 95% confidence intervals about zero. • Ljung-Box Q-statistics should be small with probability values typically in excess of 0.05.
Exponential smoothing • Very useful when we have only a handful of observations • Exponential smoothing can be modified to account for trend and seasonality. • If you suspect your data does not contain trend/seasonality, simply use single exponential smoothing: • The forecast h periods into the future is constant and given by:
Exponential smoothing with trend • Obtain the smoothed level series, Lt: • Lt=ayt+(1-a)(Lt-1+Tt-1) • The trend series, Tt is formed as: • Tt=b(Lt-Lt-1)+(1-b)(Tt-1) • The forecasted series:
Example: • Suppose the first three observations of a series are 500, 350, and 250. Suppose a=0.30, b=0.10. Suppose the trend and level are initialized such that T1=0, L1=500. • L2=0.30 (350) +(1-0.30)(500-0) = 455 • T2=0.10(455-500) + 0.90 (0) = -4.5. • The forecasted value for the third period then becomes:
Exponential smoothing: Trend and seasonality • Eviews also allows for exponential smoothing with trend and seasonality. • With seasonality we use a smoothed series along with estimates based on trends and seasonality. • Which option should I select? • If you believe your series lacks either seasonality or trend, single smoothing works perfectly. • From visual inspection of your series, if only trend appears to be present, you will need either “double smoothing” or “Holt-Winters” with “no seasonal.” • If seasonality and trend are expected, you will need to use “Holt-Winters” with the allowance of multiplicative or additive seasonality.
HUH? • Eviews provides five options when you ask it, no tell it, to provide exponential smoothing: • Single: (no seasonality/no trend) • Double: (trend – value of a=b). • Holt-Winters – No seasonal (Trend, a and b are not equal, but are estimated in the data). • Holt-Winters – Additive (Trend and Seasonality. The seasonal component is estimated with an additive filter). • Holt-Winters - Multiplicative
Breaks? • Uh oh? My data appears to have a break. • The developed time series methods assume the black box generating the data is constant. • Not necessarily true: • Learning curves may cause cost curves to decrease • Acquisition of companies or new technologies may alter sales/costs
Dealing with breaks? • Solutions: • Limit the sample to the post break period • Sometimes taking logs and/or differencing can help mitigate the effects of breaks/outliers. • Include variables that help identify the breaks • Model the breaks directly: • The most obvious way is to include a break in mean and/or a break in trend. • We should make sure that the included break is modeled in a sensible way • A negative linear trend, for example, will imply the data may eventually turn negative.
Statistics useful in comparing the out of sample forecasting accuracy • Mean squared error: For an h-step extrapolation forecast: • Root mean squared error is the square root of this number. • Mean absolute error
In Eviews: • If you have a forecasted series, say xf, and an original series x, you can calculate the mean squared error as: • genr mse=@sum((x-xf)^2)/h • To calculate the moving average forecasts: • Suppose you use the most recent four periods • Limit your data set to include only the last four observations • A variable called “maf_4” is calculated by: • genr maf_4=@mean(x)