我尝试通过sm.tsa.statespace.SARIMAX拟合Autoregression。但是我遇到警告,然后我想为此模型设置频率信息。谁曾经遇到过,您能帮我吗?
fit1 = sm.tsa.statespace.SARIMAX(train.Demand, order=(1, 0, 0),
enforce_stationarity=False,
enforce_invertibility=False).fit()
y_hat['AR'] = fit1.predict(start="1975-01-01", end="1975-12-01", dynamic=True)
plt.figure(figsize=(16,8))
plt.plot( train['Demand'], label='Train')
plt.plot(test['Demand'], label='Test')
plt.plot(y_hat_avg['AR'], label='AR')
plt.legend(loc='best')
plt.show()
C:\Users\thach.le\Anaconda3\lib\site-packages\statsmodels-0.8.0-py3.6-win-
amd64.egg\statsmodels\tsa\base\tsa_model.py:165: ValueWarning: No frequency
information was provided, so inferred frequency MS will be used.
% freq, ValueWarning)
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试将 ARMA 模型拟合到存储在 Pandas 数据帧中的时间序列。数据框有一列名为“val”的 numpy.float64 类型的值和一个熊猫时间戳索引。时间戳采用“年-月-日小时:分钟:秒”格式。我了解以下代码:
from statsmodels.tsa.arima_model import ARMA
model = ARMA(df["val"], (1,0))
Run Code Online (Sandbox Code Playgroud)
给我错误信息:
ValueError: Given a pandas object and the index does not contain dates
Run Code Online (Sandbox Code Playgroud)
因为我没有正确格式化时间戳。如何索引我的数据帧,以便 ARMA 方法在保留我的日期和时间信息的同时接受它?