Implement Box-Jenkins Model Selection and Estimation Using Econometric Modeler App
This example shows how to use the Box-Jenkins methodology to select and estimate an ARIMA model by using the Econometric Modeler app. Then, it shows how to export the estimated model to generate forecasts. The data set, which is stored inData_JAustralian.mat
, contains the log quarterly Australian Consumer Price Index (CPI) measured from 1972 and 1991, among other time series.
Prepare Data for Econometric Modeler
At the command line, load theData_JAustralian.mat
data set.
loadData_JAustralian
Convert the tableDataTable
to a timetable:
Clear the row names of
DataTable
.Convert the sampling times to a
datetime
vector.Convert the table to a timetable by associating the rows with the sampling times in
dates
.
DataTable.Properties.RowNames = {}; dates = datetime(dates,'ConvertFrom','datenum',...'Format','ddMMMyyyy','Locale','en_US'); DataTable = table2timetable(DataTable,'RowTimes',dates);
Import Data into Econometric Modeler
At the command line, open theEconometric Modeler应用程序。
econometricModeler
Alternatively, open the app from the apps gallery (seeEconometric Modeler).
ImportDataTable
into the app:
On theEconometric Modelertab, in theImportsection, click.
In theImport Datadialog box, in theImport?column, select the check box for the
DataTable
variable.ClickImport.
The variables, includingPAU
, appear in theTime Seriespane, and a time series plot of all the series appears in theTime Series Plot(EXCH)figure window.
Create a time series plot ofPAU
by double-clickingPAU
in theTime Seriespane.
The series appears nonstationary because it has a clear upward trend.
Plot Sample ACF and PACF of Series
Plot the sample autocorrelation function (ACF) and partial autocorrelation function (PACF).
In theTime Seriespane, select the
PAU
time series.Click thePlotstab, then clickACF.
Click thePlotstab, then clickPACF.
Close all figure windows except for the correlograms. Then, drag theACF(PAU)figure window above thePACF(PAU)figure window.
重要的,李nearly decaying sample ACF indicates a nonstationary process.
Close theACF(PAU)andPACF(PAU)figure windows.
Difference the Series
Take a first difference of the data. WithPAU
selected in theTime Seriespane, on theEconometric Modelertab, in theTransformssection, clickDifference.
The transformed variablePAUDiff
appears in theTime Seriespane, and its time series plot appears in theTime Series Plot(PAUDiff)figure window.
Differencing removes the linear trend. The differenced series appears more stationary.
Plot Sample ACF and PACF of Differenced Series
Plot the sample ACF and PACF ofPAUDiff
. WithPAUDiff
selected in theTime Seriespane:
Click thePlotstab, then clickACF.
Click thePlotstab, then clickPACF.
Close theTime Series Plot(PAUDiff)figure window. Then, drag theACF(PAUDiff)figure window above thePACF(PAUDiff)figure window.
差的样品ACF系列莫衰减re quickly. The sample PACF cuts off after lag 2. This behavior is consistent with a second-degree autoregressive (AR(2)) model for the differenced series.
Close theACF(PAUDiff)andPACF(PAUDiff)figure windows.
Specify and Estimate ARIMA Model
Estimate an ARIMA(2,1,0) model for the log quarterly Australian CPI. This model has one degree of nonseasonal differencing and two AR lags.
In theTime Seriespane, select the
PAU
time series.On theEconometric Modelertab, in theModelssection, clickARIMA.
In theARIMA Model Parametersdialog box, on theLag Ordertab:
SetDegree of Integrationto
1
.SetAutoregressive Orderto
2
.
ClickEstimate.
The model variableARIMA_PAU
appears in theModelspane, its value appears in thePreviewpane, and its estimation summary appears in theModel Summary(ARIMA_PAU)document.
Both AR coefficients are significant at a 5% significance level.
Check Goodness of Fit
Check that the residuals are normally distributed and uncorrelated by plotting a histogram, quantile-quantile plot, and ACF of the residuals.
Close theModel Summary(ARIMA_PAU)document.
With
ARIMA_PAU
selected in theModelspane, on theEconometric Modelertab, in theDiagnosticssection, clickResidual Diagnostics>Residual Histogram.ClickResidual Diagnostics>Residual Q-Q Plot.
ClickResidual Diagnostics>Autocorrelation Function.
In the right pane, drag theHistogram(ARIMA_PAU)andQQPlot(ARIMA_PAU)figure windows so that they occupy the upper two quadrants, and drag the ACF so that it occupies the lower two quadrants.
The residual plots suggest that the residuals are approximately normally distributed and uncorrelated. However, there is some indication of an excess of large residuals. This behavior suggests that atinnovation distribution might be appropriate.
模型导出到工作空间
Export the model to the MATLAB®Workspace.
In theTime Seriespane, select the
PAU
time series.On theEconometric Modelertab, in theExportsection, clickExport>Export Variables.
In theExport Variablesdialog box, select theSelectcheck box for theARIMA_PAUmodel.
ClickExport. The check box for thePAUtime series is already selected.
The variablesPAU
andARIMA_PAU
appear in the workspace.
Generate Forecasts at Command Line
Generate forecasts and approximate 95% forecast intervals from the estimated ARIMA(2,1,0) model for the next four years (16 quarters). Use the entire series as a presample for the forecasts.
[PAUF,PAUMSE] = forecast(ARIMA_PAU,16,'Y0',PAU); UB = PAUF + 1.96*sqrt(PAUMSE); LB = PAUF - 1.96*sqrt(PAUMSE); datesF = dates(end) + calquarters(1:16); figure h4 = plot(dates,PAU,'Color',[.75,.75,.75]); holdonh5 = plot(datesF,PAUF,'r','LineWidth',2); h6 = plot(datesF,UB,'k--','LineWidth',1.5); plot(datesF,LB,'k--','LineWidth',1.5); legend([h4,h5,h6],'Log CPI','Forecast',...'Forecast Interval','Location','Northwest') title('Log Australian CPI Forecast') holdoff
References
[1]Box, George E. P., Gwilym M. Jenkins, and Gregory C. Reinsel.Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.
See Also
Apps
Objects
Functions
Related Topics
- Econometric Modeler App Overview
- Perform ARIMA Model Residual Diagnostics Using Econometric Modeler App
- Box-Jenkins Model Selection
- Box-Jenkins Methodology
- Detect Serial Correlation Using Econometric Modeler App
- Share Results of Econometric Modeler App Session
- Creating ARIMA Models Using Econometric Modeler App