赞
踩
说明:本篇博客内容根据B站视频 整理而成,感谢UP主。
AR公式定义:
MA公式定义:
ARMA公式定义:
部分关键步骤代码(仅供参考):
import statsmodels.tsa.api as smt smt.graphics.plot_acf(data, lags=lags, ax=ax1) # ACF自相关系数 smt.graphics.plot_pacf(data, lags=lags, ax=xa2) # 偏自相关系数 # 参数介绍参见 # https://www.statsmodels.org/dev/generated/statsmodels.graphics.tsaplots.plot_pacf.html # https://www.statsmodels.org/dev/generated/statsmodels.graphics.tsaplots.plot_acf.html # Fit the model import statsmodels.api as sm model = sm.tsa.SARIMAX(train_data, order=(p,d,q)) model_results =model.fit() # Alternative model selection method, limited to only searching AR and MA parameters train_results = sm.tsa.arma_order_select_ic(ts_train, ic=['aic', 'bic'], trend='nc', max_ar=4, max_ma=4) print('AIC', train_results.aic_min_order) print('BIC', train_results.bic_min_order) #用模型进行预测 model = sm.tsa.ARIMA(train_data, order=(p, d, q),freq='W-MON') result = model.fit() pred = result.predict('xxxxxx', 'xxxxxx',dynamic=True, typ='levels') # 此处注意,前面的xxxxxx必须能在训练集数据中能够找到,后边的xxxxxx则不用 print (pred)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。