Statsmodels: BUG VAR.predict is broken

Created on 6 Jul 2018  Â·  5Comments  Â·  Source: statsmodels/statsmodels

The following error says that TimeSeriesModel (super or super's super object) has no _get_predict_start. But VAR needs it. I only find _get_predict_index in TimeSeriesModel.

File "/Users/william/Folders/临时文件夹/script.py", line 17, in
print(results.model.predict(['2015']))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statsmodels/tsa/vector_ar/var_model.py", line 535, in predict
start = self._get_predict_start(start, lags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statsmodels/tsa/vector_ar/var_model.py", line 529, in _get_predict_start
return super(VAR, self)._get_predict_start(start)
AttributeError: 'super' object has no attribute '_get_predict_start'

comp-tsa prio-elev type-bug

Most helpful comment

The bug has reappeared when trying to use predict method for VAR:
AttributeError: 'super' object has no attribute '_get_predict_start'

All 5 comments

I think, just change one of them

@Freakwill Thanks for reporting. This is most likely a refactoring victim, and AFAICS, there is no test coverage for it.

Note predict is a model method and the first argument is params. There is no corresponding results predict method for insample dynamic prediction. I only have seen the forecast method in use for VAR.
We need a unit test case to check if the function has just been renamed or has now a incompatible behavior.

You should be able to use VARMAX as workaround for dynamic insample prediction in a VAR model. VARMAXResults has predict and get_prediction and a dynamic keyword.

Yes, unfortunately the use of the new date / time handling in https://github.com/statsmodels/statsmodels/commit/6c1f892c6032ea0e3422534e4bc83d6a7735af21#diff-e2d6024b9d0ed6c0410bf2fffc1f1254R342 was overridden subsequently. I can make a PR to replace the working behavior.

Fixed by #4785 along with another bug I happened to notice.

The bug has reappeared when trying to use predict method for VAR:
AttributeError: 'super' object has no attribute '_get_predict_start'

Was this page helpful?
0 / 5 - 0 ratings