Exercise

# Forecasting with an AR Model

In addition to estimating the parameters of a model that you did in the last exercise, you can also do forecasting, both in-sample and out-of-sample using statsmodels. The in-sample is a forecast of the next data point using the data up to that point, and the out-of-sample forecasts any number of data points in the future. These forecasts can be made using either the `predict()`

method if you want the forecasts in the form of a series of data, or using the `plot_predict()`

method if you want a plot of the forecasted data. You supply the starting point for forecasting and the ending point, which can be any number of data points after the data set ends.

For the simulated series `simulated_data_1`

with \(\small \phi=0.9\), you will plot in-sample and out-of-sample forecasts.

Instructions

**100 XP**

- Import the class
`ARMA`

in the module`statsmodels.tsa.arima_model`

- Create an instance of the
`ARMA`

class called`mod`

using the simulated data`simulated_data_1`

and the order (p,q) of the model (in this case, for an AR(1)`order=(1,0)`

- Fit the model
`mod`

using the method`.fit()`

and save it in a results object called`res`

- Plot the in-sample and out-of-sample forecasts of the data using the
`plot_predict()`

method - Start the forecast 10 data points before the end of the 1000 point series at 990, and end the forecast 10 data points after the end of the series at point 1010