我正在使用ARIMA模型预测时间序列数据。我使用以下代码找到了最适合的ARIMA模型:
def run_arima_model(df, ts, p,d,q):
from statsmodels.tsa.arima_model import ARIMA
model=ARIMA(df[ts], order=(p,d,q))
results_=model.fit(disp=-1)
len_results = len(results_.fittedvalues)
ts_modified = df[ts][-len_results:]
# calculate root mean square error (RMSE) and residual sum of squares (RSS)
rss = sum((results_.fittedvalues - ts_modified)**2)
rmse = np.sqrt(rss / len(df[ts]))
# plot fit
plt.plot(df[ts])
plt.plot(results_.fittedvalues, color = 'red')
plt.title('For ARIMA model (%i, %i, %i) for ts %s, RSS: %.4f, RMSE: %.4f' %(p, d, q, ts, rss, rmse))
plt.show()
plt.close()
return results_
model_AR = run_arima_model(df,
ts = 'I',
p = 1,
d = 0,
q = 0)
# MA model with 1st order differencing - ARIMA (0,0,1)
model_MA = run_arima_model(df,
ts = 'I',
p = 0,
d = 0,
q = 1)
# ARMA model with 1st order differencing - ARIMA (1,0,1)
model_MA = run_arima_model(df,
ts = 'I',
p = 1,
d = 0,
q = 1)
ARIMA(1,0,1)最适合我的当前数据,如何获取它来预测未来点?