1. MA model estimation and forecasting
2. MA processes: changes in inflation rate - I
Let's try applying the MA model to changes in the one-month US inflation rate, available in the Mishkin data in the Ecdat package. The rate is annualized in percent with monthly observations from 1950 through 1990.
You extract the first column, apply as-dot-ts() to convert it to a time series object, and assign the result to inflation. To calculate changes in the inflation rate you apply the diff() function, and assign the result to inflation_changes. You can apply ts-plot() to note how the data was transformed. Now you will use the inflation_changes data for the rest of this chapter.
The inflation rate in the top figure wandered around, while changes in the inflation rate in the bottom figure are quickly mean reverting to zero.
3. MA processes: changes in inflation tate - II
Next, you plot the time series and its sample ACF using the ts-plot() and acf() commands as you did in earlier chapters.
The time series show the inflation_changes series is centered around zero, and has an alternating pattern, quickly changing from positive to negative.
From the ACF plot you see a strong, negative, autocorrelation estimate at lag 1, while the autocorrelation estimate at lags 2 through 24 are all near zero. The MA model may provide a good fit to these data.
4. MA processes: changes in inflation rate - III
The MA model appears in the displayed equation. To proceed, you apply the arima() function to the series inflation_changes.
Within the larger class of ARIMA models you specify order = c(0,0,1) to indicate a first-order MA model. The fitted model is assigned to MA_inflation_changes, and the print() function displays a summary.
You can find the estimates of theta, mu and sigma_squared_epsilon, which are, -0-point-7932, 0-point-0010, and 8-point-882, respectively.
Note that ma1 refers to the estimate of slope theta, intercept the estimate of the mean mu, and sigma_squared the estimate of the noise variance. Approximate standard errors appear below the coefficient estimates in the line labeled se.
5. MA processes: fitted values - I
Next, you can examine the fitted MA model. The top equations define fitted values Y-hat for the MA model. These are estimates of today given yesterday's noise.
The bottom equations are the usual definition of residuals, that is, today minus the estimate for today, or observed values minus fitted values. The residuals are denoted here as epsilon-hat. They are estimates of the white noise.
6. MA processes: fitted values - II
First, you plot the series inflation_changes. Next, you apply the residuals() function to extract the residuals from MA_inflation_changes. From the bottom equation, you can see that the fitted values are equal to the observations minus the residuals. Now you add them to the figure using the points() function. In this case, you specify a red, dashed line to depict the fitted values series.
There is a close relationship between the fitted values and the data series in the figure. The MA model explains a lot of the variation observed in the time series. More advanced models may offer an improvement, but a simple model does fairly well in this example.
7. Forecasting
Finally, you can use the predict() function to make forecasts from the last observation of the inflation_changes series. The prediction for January 1991 is about 4-point-8 percent, with a standard error of about 3-point-0.
8. Forecasting (cont.)
To forecast 6 months ahead you utilize the additional argument n-dot-ahead equals 6. This produces 1-step through 6-step forecasts. Note that the 2-step through 6-step forecasts are all exactly equal to about 0-point-001. This is because the MA model only has memory or autocorrelation for one time lag.
9. Let's practice!
That was a lot, great job! Now you try estimating and forecasting an MA model.