ARMA_ORDER_IC

This function evaluates multiple ARMA models over a grid of autoregressive and moving-average orders and returns the order pair that minimizes the selected information criterion.

Information criteria balance goodness of fit and model complexity, and common choices are Akaike information criterion (AIC), Bayesian information criterion (BIC), and Hannan-Quinn information criterion (HQIC).

The returned result is the minimizing (p, q) order for the chosen criterion.

Excel Usage

=ARMA_ORDER_IC(y, max_ar, max_ma, ic, trend)
  • y (list[list], required): Time-series observations as a 2D range (data points).
  • max_ar (int, optional, default: 4): Maximum autoregressive lag order to evaluate (lags).
  • max_ma (int, optional, default: 2): Maximum moving-average lag order to evaluate (lags).
  • ic (str, optional, default: “bic”): Information criterion name aic, bic, or hqic (option).
  • trend (str, optional, default: “c”): Deterministic trend option n or c (option).

Returns (list[list]): Single-row output containing the selected AR and MA orders as [p, q].

Example 1: Select order using BIC defaults

Inputs:

y max_ar max_ma
1 2 1.5 2.1 2 2.4 2.2 2.8 2.6 3 2 2

Excel formula:

=ARMA_ORDER_IC({1,2,1.5,2.1,2,2.4,2.2,2.8,2.6,3}, 2, 2)

Expected output:

Result
2 2
Example 2: Select order using AIC

Inputs:

y max_ar max_ma ic
5 4.8 5.1 5 5.4 5.3 5.7 5.6 5.9 6 2 1 aic

Excel formula:

=ARMA_ORDER_IC({5,4.8,5.1,5,5.4,5.3,5.7,5.6,5.9,6}, 2, 1, "aic")

Expected output:

Result
2 1
Example 3: Select order using HQIC without deterministic trend

Inputs:

y max_ar max_ma ic trend
10 11 10.5 11.2 11 11.6 11.4 12 11.8 12.3 1 2 hqic n

Excel formula:

=ARMA_ORDER_IC({10,11,10.5,11.2,11,11.6,11.4,12,11.8,12.3}, 1, 2, "hqic", "n")

Expected output:

Result
1 2
Example 4: Select order with constant trend

Inputs:

y max_ar max_ma trend
2 2.3 2.7 3 3.5 3.9 4.2 4.8 5.1 5.6 1 1 c

Excel formula:

=ARMA_ORDER_IC({2,2.3,2.7,3,3.5,3.9,4.2,4.8,5.1,5.6}, 1, 1, "c")

Expected output:

Result
1 1

Python Code

from statsmodels.tsa.stattools import arma_order_select_ic as sm_arma_order_select_ic

def arma_order_ic(y, max_ar=4, max_ma=2, ic='bic', trend='c'):
    """
    Select ARMA order using an information criterion.

    See: https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.arma_order_select_ic.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        y (list[list]): Time-series observations as a 2D range (data points).
        max_ar (int, optional): Maximum autoregressive lag order to evaluate (lags). Default is 4.
        max_ma (int, optional): Maximum moving-average lag order to evaluate (lags). Default is 2.
        ic (str, optional): Information criterion name aic, bic, or hqic (option). Valid options: AIC, BIC, HQIC. Default is 'bic'.
        trend (str, optional): Deterministic trend option n or c (option). Default is 'c'.

    Returns:
        list[list]: Single-row output containing the selected AR and MA orders as [p, q].
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        y = to2d(y)

        if not isinstance(y, list) or not all(isinstance(row, list) for row in y):
            return "Error: Invalid input - y must be a 2D list"

        series = []
        for row in y:
            for value in row:
                try:
                    series.append(float(value))
                except (TypeError, ValueError):
                    continue

        if len(series) < 6:
            return "Error: y must contain at least 6 numeric values"

        criterion = str(ic).lower().strip()
        if criterion not in ("aic", "bic", "hqic"):
            return "Error: ic must be one of aic, bic, or hqic"

        trend_value = str(trend).lower().strip()
        if trend_value not in ("n", "c"):
            return "Error: trend must be one of n or c"

        result = sm_arma_order_select_ic(
            series,
            max_ar=int(max_ar),
            max_ma=int(max_ma),
            ic=criterion,
            trend=trend_value
        )

        min_order = getattr(result, f"{criterion}_min_order", None)
        if min_order is None or len(min_order) != 2:
            return "Error: Failed to determine minimum order"

        return [[int(min_order[0]), int(min_order[1])]]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Time-series observations as a 2D range (data points).
Maximum autoregressive lag order to evaluate (lags).
Maximum moving-average lag order to evaluate (lags).
Information criterion name aic, bic, or hqic (option).
Deterministic trend option n or c (option).