ARIMA models with non-zero integ parameter can't predict.
When creating an ARIMA models with non-zero integ parameter causes PyFlux to not generate information on latent variables and causes predict(), plot_predict() and plot_z() methods to fail.
This is using PyFlux version 0.4.0.
Here's the code to reproduce the issue:
import numpy as np
import pandas as pd
import pyflux as pf
from datetime import datetime
import matplotlib.pyplot as plt
get_ipython().magic(u'matplotlib inline')
data = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/sunspot.year.csv')
data.index = data['time'].values
plt.figure(figsize=(15,5))
plt.plot(data.index,data['sunspot.year'])
plt.ylabel('Sunspots')
plt.title('Yearly Sunspot Data');
model = pf.ARIMA(data=data,ar=4,ma=4,integ=10,target='sunspot.year')
model.plot_z(indices=range(1,9))
model.plot_predict(h=20,past_values=50,figsize=(15,5))
and the traceback for plot_z():
/Users/willem/dev/ml/keras/mlpy/lib/python2.7/site-packages/pyflux/tsm.pyc in plot_z(self, indices, figsize, **kwargs) 531 Pretty plot 532 """ --> 533 self.latent_variables.plot_z(indices=indices,figsize=figsize,**kwargs) 534 535 def plot_parameters(self,indices=None,figsize=(15,5),**kwargs):
/Users/willem/dev/ml/keras/mlpy/lib/python2.7/site-packages/pyflux/latent_variables.pyc in plot_z(self, indices, figsize, loc) 229 230 else: --> 231 raise ValueError("No information on latent variable to plot!") 232 233 plt.xlabel('Value')
ValueError: No information on latent variable to plot!
<matplotlib.figure.Figure at 0x1153f5190>
And the traceback for plot_predict():
/Users/willem/dev/ml/keras/mlpy/lib/python2.7/site-packages/pyflux/arma/arma.pyc in plot_predict(self, h, past_values, intervals, **kwargs) 326 327 if self.latent_variables.estimated is False: --> 328 raise Exception("No latent variables estimated!") 329 else: 330 # Retrieve data, dates and (transformed) latent variables
Exception: No latent variables estimated!
Thanks for reporting the issue. I'll look to get this fixed for the upcoming release. Strange because I thought tests covered that, but will have a look
This issue is still occurring. Has it been rectified? On version pyflux‑0.4.15‑cp27‑cp27m‑win_amd64
modify to:
model = pf.ARIMA(data=data,ar=4,ma=4,integ=10,target='sunspot.year')
model.fit()
model.plot_z(indices=range(1,9))
and then it work