🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

ARMA/ARIMA prediction fails

ARMA/ARIMA prediction fails


When I am running this below code, this error pops up “Length of passed values is 455, index implies 123.” This code is exactly the same code as in the course file.
model_ret_ar = ARIMA(df.ret_ftse[1:], order = (5,0,0))
results_ret_ar = model_ret_ar.fit()
df_pred_ar = results_ret_ar.predict(start = start_date, end = end_date)
df_pred_ar[start_date:end_date].plot(figsize = (20,5), color = “red”)
df_test.ret_ftse[start_date:end_date].plot(color = “blue”)
plt.title(“Predictions vs Actual (Returns)”, size = 24)

ValueError                                Traceback (most recent call last)
<ipython-input-69-c08db16ba1ff> in <module>
      2 results_ret_ar = model_ret_ar.fit()
----> 4 df_pred_ar = results_ret_ar.predict(start = start_date, end = end_date)
      6 df_pred_ar[start_date:end_date].plot(figsize = (20,5), color = "red")

~\anaconda3\lib\site-packages\statsmodels\base\wrapper.py in wrapper(self, *args, **kwargs)
    113             obj = data.wrap_output(func(results, *args, **kwargs), how[0], how[1:])
    114         elif how:
--> 115             obj = data.wrap_output(func(results, *args, **kwargs), how)
    116         return obj

~\anaconda3\lib\site-packages\statsmodels\base\data.py in wrap_output(self, obj, how, names)
    443             return self.attach_cov(obj)
    444         elif how == 'dates':
--> 445             return self.attach_dates(obj)
    446         elif how == 'columns_eq':
    447             return self.attach_columns_eq(obj)

~\anaconda3\lib\site-packages\statsmodels\base\data.py in attach_dates(self, result)
    591         # May be zero-dim, for example in the case of forecast one step in tsa
    592         if squeezed.ndim < 2:
--> 593             return Series(squeezed, index=self.predict_dates)
    594         else:
    595             return DataFrame(result, index=self.predict_dates,

~\anaconda3\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    289                 try:
    290                     if len(index) != len(data):
--> 291                         raise ValueError(
    292                             f"Length of passed values is {len(data)}, "
    293                             f"index implies {len(index)}."

ValueError: Length of passed values is 455, index implies 123.

P.S. – I have also set the frequency to business days i.e. ‘b’.

4 months
1 Answer

365 Team

Hey Tushar, 
I just replicated your code and I got an output. What start/end dates are you using here? Additionally, what version of Pandas & Statsmodels are you on?

365 Vik