statsmodels.tsa.stattools.arma_order_select_ic#

statsmodels.tsa.stattools.arma_order_select_ic(y, max_ar=4, max_ma=2, ic='bic', trend='c', model_kw=None, fit_kw=None)[source]#

Compute information criteria for many ARMA models

Parameters:
yarray_like

Array of time-series data.

max_arint, optional

Maximum number of AR lags to use. Default 4.

max_maint, optional

Maximum number of MA lags to use. Default 2.

icstr or sequence of str, optional

Information criteria to report, from “aic”, “aicc”, “bic” and “hqic”. Either a single name or a sequence of names.

Changed in version 0.16.0: An unknown name raises a ValueError before any model is fitted. It used to raise an AttributeError from the first fitted model.

trend{‘n’, ‘c’}, optional

The trend to use when fitting the ARMA models.

model_kwdict, optional

Keyword arguments to be passed to the ARIMA model.

fit_kwdict, optional

Keyword arguments to be passed to ARIMA.fit.

Changed in version 0.16.0: A TypeError from model_kw or fit_kw, such as one for a mistyped keyword, is raised. It used to make every fit fail.

Returns:
Bunch

Dict-like object with attribute access. Each ic is an attribute with a DataFrame for the results. The AR order used is the row index. The ma order used is the column index. The minimum orders are available as ic_min_order, a tuple (p, q) with the AR and MA orders of the model with the smallest criterion. Models with a NaN criterion, such as those whose fit failed, are ignored.

Changed in version 0.16.0: The minimum orders ignore models with a NaN criterion. They used to point at the first such model whenever a fit had failed.

Raises:
ValueError

If ic contains an unknown name, if the fit of every model fails, or if no model has a non-NaN value of a criterion in ic.

TypeError

If model_kw or fit_kw are not valid arguments of ARIMA or ARIMA.fit, for example because of a mistyped keyword.

Warns:
EstimationWarning

If the fits of some, but not all, models fail. The warning lists their orders and the error raised by the first.

Added in version 0.16.0.

Notes

This method can be used to tentatively identify the order of an ARMA process, provided that the time series is stationary and invertible. This function computes the full exact MLE estimate of each model and can therefore be a little slow. A faster, approximate estimator of ARIMA.fit can be selected with fit_kw, for example fit_kw={"method": "hannan_rissanen"}.

A model whose fit fails has NaN information criteria, and the minimum orders ignore it.

Examples

>>> from statsmodels.tsa.arima_process import arma_generate_sample
>>> import statsmodels.api as sm
>>> import numpy as np
>>> arparams = np.array([.75, -.25])
>>> maparams = np.array([.65, .35])
>>> arparams = np.r_[1, -arparams]
>>> maparams = np.r_[1, maparams]
>>> nobs = 250
>>> np.random.seed(2014)
>>> y = arma_generate_sample(arparams, maparams, nobs)
>>> res = sm.tsa.arma_order_select_ic(y, ic=["aic", "bic"], trend="n")
>>> res.aic_min_order
>>> res.bic_min_order