.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples\forecasting\plot_arima_search.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download__examples_forecasting_plot_arima_search.py>` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_forecasting_plot_arima_search.py: ARIMA - Search --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 6-115 .. image-sg:: /_examples/forecasting/images/sphx_glr_plot_arima_search_001.png :alt: Non-dynamic predictions for ARIMA :srcset: /_examples/forecasting/images/sphx_glr_plot_arima_search_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 4/128. ARIMA(0, 1, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 6/128. ARIMA(2, 2, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 8/128. ARIMA(2, 1, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 10/128. ARIMA(0, 1, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 12/128. ARIMA(0, 3, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 14/128. ARIMA(2, 1, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 16/128. ARIMA(0, 3, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 18/128. ARIMA(3, 2, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 20/128. ARIMA(1, 2, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 22/128. ARIMA(1, 3, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 24/128. ARIMA(3, 1, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 26/128. ARIMA(1, 3, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 28/128. ARIMA(3, 3, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 32/128. ARIMA(2, 3, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 34/128. ARIMA(0, 2, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 38/128. ARIMA(2, 3, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 40/128. ARIMA(1, 1, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 44/128. ARIMA(1, 1, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 50/128. ARIMA(2, 1, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 52/128. ARIMA(2, 2, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 54/128. ARIMA(0, 1, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 56/128. ARIMA(0, 3, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 58/128. ARIMA(3, 1, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 60/128. ARIMA(3, 2, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 62/128. ARIMA(1, 2, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 66/128. ARIMA(1, 3, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 68/128. ARIMA(3, 2, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 70/128. ARIMA(3, 3, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 74/128. ARIMA(0, 2, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 78/128. ARIMA(2, 3, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 80/128. ARIMA(0, 2, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 82/128. ARIMA(1, 1, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 94/128. ARIMA(2, 2, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 96/128. ARIMA(0, 1, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 98/128. ARIMA(2, 2, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 100/128. ARIMA(2, 1, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 102/128. ARIMA(0, 3, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 104/128. ARIMA(1, 2, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 106/128. ARIMA(3, 1, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 108/128. ARIMA(1, 3, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 110/128. ARIMA(1, 2, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 112/128. ARIMA(3, 1, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 114/128. ARIMA(3, 2, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 116/128. ARIMA(3, 3, 3) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 118/128. ARIMA(3, 3, 0) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 122/128. ARIMA(2, 3, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 124/128. ARIMA(0, 2, 2) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. 128/128. ARIMA(1, 1, 1) [c, False] ... failed: In models with integration (`d > 0`) or seasonal integration (`D > 0`), trend terms of lower order than `d + D` cannot be (as they would be eliminated due to the differencing operation). For example, a constant cannot be included in an ARIMA(1, 1, 1) model, but including a linear trend, which would have the same effect as fitting a constant to the differenced data, is allowed. Summary: arima-order arima-trend arima-aic arima-bic 0 (0, 2, 2) n 764.0096 771.0797 1 (1, 2, 1) n 765.0853 772.1555 2 (1, 1, 0) n 770.2782 775.0171 3 (0, 1, 1) n 770.4979 775.2368 4 (0, 2, 3) n 765.991 775.4179 .. ... ... ... ... 62 (0, 0, 1) c 937.348 944.4941 63 (0, 0, 2) n 1008.9601 1016.1062 64 (0, 0, 0) c 1014.6352 1019.3993 65 (0, 0, 1) n 1076.0548 1080.8188 66 (0, 0, 0) n 1173.6025 1175.9846 [67 rows x 4 columns] 0. Estimator (bic=771.08): ARIMA(0, 2, 2) [n, False] 1. Estimator (bic=772.16): ARIMA(1, 2, 1) [n, False] 2. Estimator (bic=775.02): ARIMA(1, 1, 0) [n, False] 3. Estimator (bic=775.24): ARIMA(0, 1, 1) [n, False] 4. Estimator (bic=775.42): ARIMA(0, 2, 3) [n, False] 5. Estimator (bic=775.42): ARIMA(1, 2, 2) [n, False] 6. Estimator (bic=775.53): ARIMA(2, 2, 1) [n, False] 7. Estimator (bic=776.41): ARIMA(0, 3, 3) [n, False] 8. Estimator (bic=776.77): ARIMA(0, 2, 1) [n, False] | .. code-block:: default :lineno-start: 6 # Import. import sys import warnings import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt # Import ARIMA from statsmodels. from statsmodels.tsa.arima.model import ARIMA # import weights. from pyamr.datasets.load import make_timeseries from pyamr.core.regression.arima import ARIMAWrapper # Filter warnings warnings.simplefilter(action='ignore', category=FutureWarning) # ---------------------------- # set basic configuration # ---------------------------- # Matplotlib options mpl.rc('legend', fontsize=6) mpl.rc('xtick', labelsize=6) mpl.rc('ytick', labelsize=6) # Set pandas configuration. pd.set_option('display.max_colwidth', 14) pd.set_option('display.width', 150) pd.set_option('display.precision', 4) # ---------------------------- # create data # ---------------------------- # Create timeseries data x, y, f = make_timeseries() # Create exogenous variable exog = x # Variables. s, e = 50, 120 # ------------------------------- # create arima model # ------------------------------- # This example shows how to use auto to find the best overall model using # a particular seletion criteria. It also demonstrates how to plot the # resulting data for visualization purposes. Note that it only prints # the top best classifier according to the information criteria. # Find the best arima model (bruteforce). models, best = ARIMAWrapper(estimator=ARIMA) \ .auto(endog=y[:80], ic='bic', max_ar=3, max_ma=3, max_d=3, return_fits=True) # Sort the list (from lower to upper) models.sort(key=lambda x: x.bic, reverse=False) # Summary summary = ARIMAWrapper().from_list_dataframe(models) # Show summary print("\nSummary:") print(summary[['arima-order', 'arima-trend', 'arima-aic', 'arima-bic']]) # ------------------------------- # plot results # ------------------------------- # Create figure fig, axes = plt.subplots(3,3, figsize=(10,6)) axes = axes.flatten() # Loop for the selected models for i,estimator in enumerate(models[:9]): # Show information print("%2d. Estimator (bic=%.2f): %s " % \ (i, estimator.bic, estimator._identifier())) # Get the predictions preds = estimator.get_prediction(start=s, end=e, dynamic=False) # Plot truth values. axes[i].plot(y, color='#A6CEE3', alpha=0.5, marker='o', markeredgecolor='k', markeredgewidth=0.5, markersize=5, linewidth=0.75, label='Observed') # Plot forecasted values. axes[i].plot(preds[0,:], preds[1,:], color='#FF0000', alpha=1.00, linewidth=2.0, label=estimator._identifier()) # Plot the confidence intervals. axes[i].fill_between(preds[0,:], preds[2,:], preds[3,:], color='#FF0000', alpha=0.25) # Configure axes axes[i].legend(loc=3) axes[i].grid(True, linestyle='--', linewidth=0.25) # Set superior title plt.suptitle("Non-dynamic predictions for ARIMA") # Show plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 9.920 seconds) .. _sphx_glr_download__examples_forecasting_plot_arima_search.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_arima_search.py <plot_arima_search.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_arima_search.ipynb <plot_arima_search.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_