Python中的Statsmodels包 - 检索ARIMA模型的样本外预测存在问题

3

我正在尝试获取ARIMA模型的样本外预测值。然而,我一直收到错误提示,不确定该如何继续:( 以下是代码:

    from statsmodels.tsa.arima_model import ARIMA
    fit = ARIMA(endog, (1,1,1)).fit()
    params = fit.params
    forecast = fit.predict(params.all(), start='2015-9-21', end='2016-9-21', typ='levels')

当我仅使用时,它能够很好地工作(即给我一个结果,但不是一个样外的结果……)。
    forecast = fit.predict(params.all(), typ='levels')

但是,当我添加了“开始”和“结束”日期(或仅“开始”)时,它就无法工作了,我不断收到错误。在第一段引用的代码情况下,“TypeError: predict() got multiple values for keyword argument 'start'”。我还尝试过datetime类型,但也没有成功。有人可以帮助我吗?

自从0.6版本以来,对于这个问题进行了几次修复。例如,不支持结束日期(end datetime) https://github.com/statsmodels/statsmodels/issues/2587 我不记得起始日期有任何问题。但是,问题可能在于结果实例的预测方法(predict method)没有params作为参数。请尝试fit.predict(start='2015-9-21', end='2016-9-21', typ='levels') - Josef
3
你好!谢谢你的提示 - 我尝试了没有参数作为参数,但这次出现了错误 "AttributeError: 'NoneType' object has no attribute 'get_loc'" :( - MBpleasehelp
2
@MBseekingforhelp 你已经得到答案了吗?我也遇到了 "AttributeError: 'NoneType' object has no attribute 'get_loc' "。 - F. Suyuti
2个回答

0

我遇到了与上面报告的类似错误:

"AttributeError: 'NoneType' object has no attribute 'get_loc' "

但是我意识到这是因为我传递了一个没有日期时间索引的数组(或列表),例如,如果您使用pandas数据框并将其输入为df.values,然后删除时间索引,则ARMA没有日期信息(因此日期为None),从而触发此错误。我建议您提供带有日期时间索引的pd.DataFramepd.Series对象。另请参见此线程http://pystatsmodels.narkive.com/rhX3T509/arma-predict-throws-attributeerror-with-start-and-end-dates


0

您可以使用

fit.forecast(steps, exog=None, alpha=0.05)

如果按月计算,根据您的startend参数,steps=365。请参考this answer


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接