【问题标题】:I would like to know "SARIMA(statsmodels) parameter" [order] and [seasonal_order]. how should I choose?我想知道“SARIMA(statsmodels) 参数”[order] 和 [seasonal_order]。我应该如何选择?
【发布时间】:2019-07-11 01:33:44
【问题描述】:

我的数据(时间序列)包含两年的数据。(一个值/天,行=360*2)

现在,我尝试使用来自 statsmodels 的 SARIMA 模型。 我随机选择了参数(订单和季节性订单)。 order=(1,0,1),seasonal_order=(0,1,0,360) 它非常适合我的数据。

但我本质上并没有被理解。 我应该如何选择参数(p,d,q)? order=(P,D,Q),seasonal_order=(p,d,q,s=360?) 我可以从 ACF 或 PACF 图中读取它吗?还是 AIC,BIC 来自摘要?

(我尝试从“最小AIC模型”中选择它。但效果不佳)


import statsmodels.api as sm
SARIMA_1_0_1_010 = sm.tsa.SARIMAX(t3, order=(1,0,1), seasonal_order=(0,1,0,300)).fit()
print(SARIMA_1_0_1_010.summary())

residSARIMA = SARIMA_1_0_1_010.resid
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(211)
fig = sm.graphics.tsa.plot_acf(residSARIMA.values.squeeze(), lags=100, ax=ax1)
ax2 = fig.add_subplot(212)
fig = sm.graphics.tsa.plot_pacf(residSARIMA, lags=100, ax=ax2)


pred = SARIMA_1_0_1_010.predict(700, 1200)
plt.figure(figsize=(22,10))
plt.plot(t3)
plt.plot(pred, "r")



max_p = 3
max_q = 3
max_d = 1
max_sp = 0
max_sq = 0
max_sd = 0

pattern = max_p*(max_q + 1)*(max_d + 1)*(max_sp + 1)*(max_sq + 1)*(max_sd + 1)
modelSelection = pd.DataFrame(index=range(pattern), columns=["model", "aic"])

season = 360

num = 0

for p in range(1, max_p + 1):
    for d in range(0, max_d + 1):
        for q in range(0, max_q + 1):
            for sp in range(0, max_sp + 1):
                for sd in range(0, max_sd + 1):
                    for sq in range(0, max_sq + 1):
                        sarima = sm.tsa.SARIMAX(
                            t3, order=(p,d,q), 
                            seasonal_order=(sp,sd,sq,360), 
                            enforce_stationarity = False, 
                            enforce_invertibility = False
                        ).fit()
                        modelSelection.ix[num]["model"] = "order=(" + str(p) + ","+ str(d) + ","+ str(q) + "), season=("+ str(sp) + ","+ str(sd) + "," + str(sq) + ")"
                        modelSelection.ix[num]["aic"] = sarima.aic
                        modelSelection.ix[num]["bic"] = sarima.bic

                        num = num + 1

modelSelection[modelSelection.aic == min(modelSelection.aic)]

预测不好……

【问题讨论】:

    标签: python-3.x time-series statsmodels arima


    【解决方案1】:

    这里的基本问题是SARIMAX 在季节性影响很长的情况下不是一个很好的模型(参见例如https://stats.stackexchange.com/questions/117953/very-high-frequency-time-series-analysis-seconds-and-forecasting-python-r/118050#118050)。

    一般来说,通过信息标准选择模型的阶数(例如 p、q 和 P、Q)是一个好主意,但这样选择差分阶数(d 或 D)并不是一个好主意。

    在使用SARIMAX 模型时可以帮助自动选择模型的python 包是https://github.com/tgsmith61591/pmdarima

    但是,我应该重申,这通常不适用于季节长度为 360 的模型。

    【讨论】:

    • 谢谢!我必须了解更多。你的“网址”很有用,给了我新的知识!
    猜你喜欢
    • 2022-08-24
    • 2021-06-19
    • 1970-01-01
    • 2017-05-05
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 2019-02-27
    • 2023-03-13
    相关资源
    最近更新 更多