Reputation: 7089
I'm trying to use statsmodels to forecast an ARIMA model with exogenous variables. Using a series of exogenous variables going eight periods into the future, I run the following command:
prediction = dynamic_arima_results.forecast(steps=8, exog=X_pred)
And get the following error:
Traceback (most recent call last):
File "<ipython-input-1-9cfb206405a4>", line 41, in evaluate_model
prediction = dynamic_arima_results.forecast(steps=8, exog=X_pred)
File ".../arima_model.py", line 1603, in forecast exog, method=self.model.method)
File ".../arima_model.py", line 235, in _arma_predict_out_of_sample exog)
File ".../arima_model.py", line 206, in _get_predict_out_of_sample
X = lagmat(np.dot(exog, exparams), p, original='in', trim='both')
ValueError: matrices are not aligned
After poking around a bit, it seems that the error is coming from the dot product: np.dot(exog, exparams)
step. exog
is the series of 8 exogenous values, one for each period in the future, but exparams
is a single value, the coefficient on the exogenous variable I assume.
Forecasting produces a result if I only predict a single step in advance and only pass in a single value for the exogenous variable. Am I doing something obviously silly or is multi-period forecasting with exogenous variables not implemented yet?
Upvotes: 2
Views: 2343
Reputation: 8283
Yes. This is a bug. I assume you're on 0.5.0? This should be fixed in master and will be fixed in the next release. In the meantime, I'd try to upgrade if you can. See documentation for building from github or installing nightly binaries if you're on windows.
You can search SO and github issues for more information about the error.
Upvotes: 2