HANNAN_RISSANEN
This function estimates autoregressive and moving-average parameters for a stationary time series using the Hannan-Rissanen multi-step approach.
The procedure fits a high-order autoregression to obtain residuals, then estimates ARMA coefficients using least squares, with an optional bias-correction stage when conditions are satisfied.
The function returns a row vector of estimated ARMA parameter values.
Excel Usage
=HANNAN_RISSANEN(endog, ar_order, ma_order, demean, initial_ar_order)
endog(list[list], required): Time-series observations as a 2D range (data points).ar_order(int, optional, default: 0): Autoregressive order to estimate (lags).ma_order(int, optional, default: 0): Moving-average order to estimate (lags).demean(bool, optional, default: true): Whether to remove the mean before estimation (true/false).initial_ar_order(int, optional, default: 0): Initial long autoregressive order used in first-stage residual estimation (lags).
Returns (list[list]): Row vector containing estimated ARMA parameter values.
Example 1: Hannan-Rissanen estimation for ARMA(1,1)
Inputs:
| endog | ar_order | ma_order | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 5.2 | 5.1 | 5.4 | 5.3 | 5.6 | 5.5 | 5.8 | 5.7 | 6 | 1 | 1 |
Excel formula:
=HANNAN_RISSANEN({5,5.2,5.1,5.4,5.3,5.6,5.5,5.8,5.7,6}, 1, 1)
Expected output:
| Result | ||
|---|---|---|
| 0.466012 | 1.78856 | 0.0950253 |
Example 2: Hannan-Rissanen estimation for AR(2)
Inputs:
| endog | ar_order | ma_order | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 12 | 12.5 | 12.1 | 12.8 | 12.4 | 13 | 12.7 | 13.3 | 13 | 13.6 | 2 | 0 |
Excel formula:
=HANNAN_RISSANEN({12,12.5,12.1,12.8,12.4,13,12.7,13.3,13,13.6}, 2, 0)
Expected output:
| Result | ||
|---|---|---|
| 0.0857862 | 0.855313 | 0.0929974 |
Example 3: Hannan-Rissanen estimation for MA(1)
Inputs:
| endog | ar_order | ma_order | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 3 | 2.9 | 3.1 | 3 | 3.2 | 3.1 | 3.3 | 3.2 | 3.4 | 3.3 | 0 | 1 |
Excel formula:
=HANNAN_RISSANEN({3,2.9,3.1,3,3.2,3.1,3.3,3.2,3.4,3.3}, 0, 1)
Expected output:
| Result | |
|---|---|
| 0.197778 | 0.0257315 |
Example 4: Hannan-Rissanen with explicit initial AR order
Inputs:
| endog | ar_order | ma_order | initial_ar_order | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 8 | 8.3 | 8.1 | 8.5 | 8.2 | 8.6 | 8.4 | 8.8 | 8.6 | 9 | 1 | 1 | 4 |
Excel formula:
=HANNAN_RISSANEN({8,8.3,8.1,8.5,8.2,8.6,8.4,8.8,8.6,9}, 1, 1, 4)
Expected output:
| Result | ||
|---|---|---|
| -2.2046 | 5.07056 | 0.0426358 |
Python Code
import numpy as np
from statsmodels.tsa.arima.model import hannan_rissanen as sm_hannan_rissanen
def hannan_rissanen(endog, ar_order=0, ma_order=0, demean=True, initial_ar_order=0):
"""
Estimate ARMA parameters using the Hannan-Rissanen procedure.
See: https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima.model.hannan_rissanen.html
This example function is provided as-is without any representation of accuracy.
Args:
endog (list[list]): Time-series observations as a 2D range (data points).
ar_order (int, optional): Autoregressive order to estimate (lags). Default is 0.
ma_order (int, optional): Moving-average order to estimate (lags). Default is 0.
demean (bool, optional): Whether to remove the mean before estimation (true/false). Default is True.
initial_ar_order (int, optional): Initial long autoregressive order used in first-stage residual estimation (lags). Default is 0.
Returns:
list[list]: Row vector containing estimated ARMA parameter values.
"""
try:
def to2d(x):
return [[x]] if not isinstance(x, list) else x
endog = to2d(endog)
if not isinstance(endog, list) or not all(isinstance(row, list) for row in endog):
return "Error: Invalid input - endog must be a 2D list"
series = []
for row in endog:
for value in row:
try:
series.append(float(value))
except (TypeError, ValueError):
continue
if len(series) < 6:
return "Error: endog must contain at least 6 numeric values"
init_order = None if int(initial_ar_order) <= 0 else int(initial_ar_order)
params, _ = sm_hannan_rissanen(
series,
ar_order=int(ar_order),
ma_order=int(ma_order),
demean=bool(demean),
initial_ar_order=init_order
)
if hasattr(params, "params"):
values = np.asarray(params.params, dtype=float).ravel()
elif hasattr(params, "to_array"):
values = np.asarray(params.to_array(), dtype=float).ravel()
else:
values = np.asarray(params, dtype=float).ravel()
return [values.tolist()]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Time-series observations as a 2D range (data points).
Autoregressive order to estimate (lags).
Moving-average order to estimate (lags).
Whether to remove the mean before estimation (true/false).
Initial long autoregressive order used in first-stage residual estimation (lags).