我试图借助此link在自己的数据上实现ARIMA。 (每日)数据由日期时间索引和一列值组成。
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 1094 entries, 2013-01-01 to 2015-12-31
Data columns (total 1 columns):
Value 1094 non-null int64
dtypes: int64(1)
memory usage: 57.1 KB
我在使用get_forecast时遇到TypeError,其代码和完整错误如下。 请帮我解决这个问题。
代码
# Get forecast 6 steps (1/2 year) ahead in future
n_steps = 6
pred_uc_99 = best_results.get_forecast(steps=6, alpha=0.01) # alpha=0.01 signifies 99% confidence interval
pred_uc_95 = best_results.get_forecast(steps=6, alpha=0.05) # alpha=0.05 95% CI
# Get confidence intervals 95% & 99% of the forecasts
pred_ci_99 = pred_uc_99.conf_int()
pred_ci_95 = pred_uc_95.conf_int()
错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-65-732144d7938c> in <module>()
1 # Get forecast 12 steps (1 year) ahead in future
2 n_steps = 6
----> 3 pred_uc_99 = best_results.get_forecast(steps=6, alpha=0.01) # alpha=0.01 signifies 99% confidence interval
4 pred_uc_95 = best_results.get_forecast(steps=6, alpha=0.05) # alpha=0.05 95% CI
5
C:\Users\...\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py in get_forecast(self, steps, **kwargs)
2329 else:
2330 end = steps
-> 2331 return self.get_prediction(start=self.nobs, end=end, **kwargs)
2332
2333 def predict(self, start=None, end=None, dynamic=False, **kwargs):
C:\Users\...\Anaconda3\lib\site-packages\statsmodels\tsa\statespace\sarimax.py in get_prediction(self, start, end, dynamic, exog, **kwargs)
1880
1881 # Handle end (e.g. date)
-> 1882 _start = self.model._get_predict_start(start)
1883 _end, _out_of_sample = self.model._get_predict_end(end)
1884
C:\Users\...\Anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py in _get_predict_start(self, start)
139 (str(start), str(dtstart)))
140
--> 141 self._set_predict_start_date(start)
142 return start
143
C:\Users\...\Anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py in _set_predict_start_date(self, start)
113 if start == len(dates):
114 self.data.predict_start = datetools._date_from_idx(dates[-1],
--> 115 1, self.data.freq)
116 elif start < len(dates):
117 self.data.predict_start = dates[start]
C:\Users\...\Anaconda3\lib\site-packages\statsmodels\tsa\base\datetools.py in _date_from_idx(d1, idx, freq)
84 offset. For now, this needs to be taken care of before you get here.
85 """
---> 86 return _maybe_convert_period(d1) + int(idx) * _freq_to_pandas[freq]
87
88
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'