问题描述
我生成了一些数据,如 [1, 6, 1, 6, 1, 6] 并在正态分布下添加噪声.我使用 arma_order_select_ic
来选择订单.然后使用 aic_min_order 拟合 ARMA 模型.有时该模型运行良好.但有时它会引发 ValueError.
I generate some data like [1, 6, 1, 6, 1, 6] and add noises under normal distribution. I use arma_order_select_ic
to select order. Then aic_min_order is used to fit the ARMA model. Sometime the model works well. But sometimes it raises ValueError.
ValueError: 计算出的初始 AR 系数不是平稳的
这是我的代码.
import statsmodels.api as sm
import numpy as np
x = [1 if i%2 == 0 else 6 for i in range(50)]
eta = np.random.normal(0, 0.01, 50)
x = x + eta
res = sm.tsa.stattools.arma_order_select_ic(x, ic=['aic'])
print res.aic_min_order
model = sm.tsa.ARMA(x, res.aic_min_order).fit(disp = 0)
print model.predict(45, 55)
我是否遗漏了什么或 ARMA 不适合这种数据?
Do I miss something or ARMA don't fit this kind of data?
推荐答案
ARMA 专为平稳过程而设计,默认情况下对参数估计施加平稳性.
ARMA is designed for stationary processes and by default imposes stationarity on the parameter estimates.
您的数据不是平稳的,即滞后多项式具有季节性单位根.通常的处理方法是使用季节性差分或确定性季节性模式,例如使用虚拟变量或样条.
Your data is not stationary, i.e. it the lag polynomial has a seasonal unit root. The usual treatment is to use seasonal differencing or a deterministic seasonal pattern for example with dummy variables or splines.
Statsmodels 目前没有自动季节检测和模型选择,但 SARIMAX 可用于季节性集成 ARMA 过程.
Statsmodels has currently no automatic season detection and model selection, but SARIMAX can be used for seasonal integrated ARMA processes.
这篇关于为什么我在使用 aic_min_order 时得到“计算的初始 AR 系数不是平稳的"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!