Forecasting simulated ARIMA
Now that you are an expert at fitting ARIMA models, you can use your skills for forecasting. First, you will work with simulated data.
We generated 120 observations from an ARIMA(1,1,0) model with AR parameter .9. The data are in y
and the first 100 observations are in x
. These observations are plotted for you. You will fit an ARIMA(1,1,0) model to the data in x
and verify that the model fits well. Then use sarima.for() from astsa
to forecast the data 20 time periods ahead. You will then compare the forecasts to the actual data in y
.
The basic syntax for forecasting is sarima.for(data, n.ahead, p, d, q)
where n.ahead
is a positive integer that specifies the forecast horizon. The predicted values and their standard errors are printed, the data are plotted in black, and the forecasts are in red along with 2 mean square prediction error bounds as blue dashed lines.
The astsa package is preloaded and the data (x
) and differenced data (diff(x)
) are plotted.
Este ejercicio forma parte del curso
ARIMA Models in R
Instrucciones del ejercicio
- Plot the sample ACF and PACF of the differenced data to determine a model.
- Use
sarima()
to fit an ARIMA(1,1,0) to the data. Examine the output of yoursarima()
command to assess the fit and model diagnostics. - Use
sarima.for()
to forecast the data 20 time periods ahead. Compare it to the actual values.
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
# Plot P/ACF pair of differenced data
# Fit model - check t-table and diagnostics
# Forecast the data 20 time periods ahead
sarima.for(x, n.ahead = ___, p = ___, d = ___, q = ___)
lines(y)