This example shows how to choose lags for an ARIMA model by
comparing the AIC values of estimated models using the Econometric
Modeler app. The example also shows how to compare the predictive
performance of several models that have the best in-sample fits at the command line.
The data set, which is stored in
mlr/examples/econ/Data_Airline.mat, contains monthly counts of airline
passengers. The folder
mlr is the value of
At the command line, load the
Data_Airline.mat data set.
To compare predictive performance later, reserve the last two years of data as a holdout sample.
fHorizon = 24; HoldoutTable = DataTable((end - fHorizon + 1):end,:); DataTable((end - fHorizon + 1):end,:) = ;
At the command line, open the Econometric Modeler app.
Alternatively, open the app from the apps gallery (see Econometric Modeler).
DataTable into the app:
On the Econometric Modeler tab, in the Import section, click .
In the Import Data dialog box, in the
Import? column, select the check box for the
PSSG appears in the Data
Browser, and its time series plot appears in the Time
Series Plot(PSSG) figure window.
The series exhibits a seasonal trend, serial correlation, and possible exponential growth. For an interactive analysis of serial correlation, see Detect Serial Correlation Using Econometric Modeler App.
Address the exponential trend by applying the log transform to
In the Data Browser, select
On the Econometric Modeler tab, in the Transforms section, click Log.
The transformed variable
appears in the Data Browser, and its time series plot
appears in the Time Series Plot(PSSGLog) figure
The exponential growth appears to be removed from the series.
Box, Jenkins, and Reinsel suggest a
SARIMA(0,1,1)×(0,1,1)12 model without a constant for
 (for more
details, see Estimate Multiplicative ARIMA Model Using Econometric Modeler App). However,
consider all combinations of monthly SARIMA models that include up to two
seasonal and nonseasonal MA lags. Specifically, iterate the following steps for
each of the nine models of the form
where q ∈
and q12 ∈
For the first iteration:
Let q = q12 = 0.
PSSGLog selected in the
Data Browser, click the
Econometric Modeler tab. In the
Models section, click the arrow to
display the models gallery.
In the models gallery, in the ARMA/ARIMA Models section, click SARIMA.
In the SARIMA Model Parameters dialog box, on the Lag Order tab:
Set Degrees of
Set Moving Average
Clear the Include Constant Term check box.
Set Period to
12 to indicate monthly
Set Moving Average
Select the Include Seasonal Difference check box.
Rename the new model variable.
In the Data Browser, right-click the new model variable.
In the context menu, select Rename.
For example, when
= 0, rename the variable to
In the Model
document, in the Goodness of Fit table, note the
AIC value. For example, for the model variable
SARIMA010x010, the AIC is in this
For the next iteration, chose values of q and q12. For example, q = 0 and q12 = 1 for the second iteration.
In the Data Browser, right-click
In the context menu, select Modify to open
the SARIMA Model Parameters dialog box with the
current settings for the selected model.
In the SARIMA Model Parameters dialog box:
In the Nonseasonal section, set
Moving Average Order to
In the Seasonal section, set
Moving Average Order to
After you complete the steps, the Models section of the
Data Browser contains nine estimated models named
The resulting AIC values are in this table.
The three models yielding the lowest three AIC values are SARIMA(0,1,1)×(0,1,1)12, SARIMA(0,1,1)×(0,1,2)12, and SARIMA(0,1,2)×(0,1,1)12. These models have the best parsimonious in-sample fit.
Export the models with the best in-sample fits.
On the Econometric Modeler tab, in the Export section, click .
In the Export Variables dialog box, in the
Models column, click the
Select check box for the
SARIMA012x011. Clear the check box
for any other selected models.
arima model objects
SARIMA012x011 appear in the MATLAB® Workspace.
At the command line, estimate two-year-ahead forecasts for each model.
f5 = forecast(SARIMA_PSSGLog5,fHorizon); f6 = forecast(SARIMA_PSSGLog6,fHorizon); f8 = forecast(SARIMA_PSSGLog8,fHorizon);
24-by-1 vectors containing the forecasts.
Estimate the prediction mean square error (PMSE) for each of the forecast vectors.
logPSSGHO = log(HoldoutTable.Variables); pmse5 = mean((logPSSGHO - f5).^2); pmse6 = mean((logPSSGHO - f6).^2); pmse8 = mean((logPSSGHO - f8).^2);
Identify the model yielding the lowest PMSE.
[~,bestIdx] = min([pmse5 pmse6 pmse8],,2)
The SARIMA(0,1,1)×(0,1,1)12 model performs the best in-sample and out-of-sample.
 Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.