You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
arma_order_select_ic function throw "IndexError: index 0 is out of bounds for axis 0 with size 0" #4727
Hi, I got a problem when I run the code sm.tsa.arma_order_select_ic(ts,max_ar=6,max_ma=4,ic='aic')['aic_min_order'] # AIC with my dataset.
The problem showed below:
~/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/stattools.py in arma_order_select_ic(y, max_ar, max_ma, ic, trend, model_kw, fit_kw)
1149 for i, result in iteritems(res):
1150 mins = np.where(result.min().min() == result)
-> 1151 min_res.update({i + '_min_order' : (mins[0][0], mins[1][0])})
1152 res.update(min_res)
1153
IndexError: index 0 is out of bounds for axis 0 with size 0
However, I just cannot figure what is going on. And When I run the sample code, there is no problem. So what caused this problem? Is there something wrong with my dataset?
result = pd.DataFrame(np.nan * np.arange(12).reshape(4, 3))
np.where(result.min().min() == result)
Out[21]: (array([], dtype=int64), array([], dtype=int64))
np.where(result.min().min() == result)[0][0]
Traceback (most recent call last):
File "<ipython-input-23-83c722093758>", line 1, in <module>
np.where(result.min().min() == result)[0][0]
IndexError: index 0 is out of bounds for axis 0 with size 0
Hi, josef-pkt, thanks very much for your response. I just find the error is because the parameter that arma_order_select_ic need to be numpy.ndarray. However, the ts is Series type.
So when I changed the code to sm.tsa.arma_order_select_ic(ts.values,max_ar=6,max_ma=4,ic='aic')['aic_min_order'] # AIC. Everything is fine. Thanks again~
There is something strange
y goes directly into ARIMA, so it should be fine.
Most likely there is something in the results wrapper that changes things,
in many other cases we get the _results below the results wrapper for further computation.
However, AFAICS only the ic are taken from the results instance.
Sorry to come back with this topic but I'm struggling a bit with the same scenario having the IndexError: index 0 is out of bounds for axis 0 with size 0 error.
I'll paste the snippet of code here. Basically the data source comes from a pandas Series coming from a DataFrame which has been converted into np.array in order to avoid the error.
Not sure why. I've tried to convert the data into arrays via few methods like the one in the example, the .values, np.asarray, etc and still giving the same error. Basically what I'm tring to get is the SBIC and AIC for the series as you can imagine.
The version is statsmodels 0.13.2.
If you can give a hand with this would be really appreciated. As said, not sure if it is me doing something wrong or is a general issue.
Activity
lbdhr commentedon Jun 7, 2018
For
ts, after runts.tail(), the printed information is:josef-pkt commentedon Jun 7, 2018
which version of pandas are you using?
Can you use pdb to check what
resultandminsis?Result is a pandas.DataFrame, but I don't see why
minsshould be empty or not a tuple.i.e. somthing like
unless all results are nan
lbdhr commentedon Jun 7, 2018
Hi, josef-pkt, thanks very much for your response. I just find the error is because the parameter that arma_order_select_ic need to be
numpy.ndarray. However, thetsisSeriestype.So when I changed the code to
sm.tsa.arma_order_select_ic(ts.values,max_ar=6,max_ma=4,ic='aic')['aic_min_order'] # AIC. Everything is fine. Thanks again~josef-pkt commentedon Jun 7, 2018
I added bug label
There is something strange
y goes directly into ARIMA, so it should be fine.
Most likely there is something in the results wrapper that changes things,
in many other cases we get the
_resultsbelow the results wrapper for further computation.However, AFAICS only the
icare taken from the results instance.josef-pkt commentedon Jun 7, 2018
Whatever the reason, we don't need pandas in the order search, so we can just put an np.asarray into arma_order_select_ic
BUG: Add check to ensure array in arma order selection
BUG: Add check to ensure array in arma order selection
BUG: Add check to ensure array in arma order selection
BUG: Add check to ensure array in arma order selection
JavierCastilloGuillen commentedon Apr 21, 2022
Hi guys,
Sorry to come back with this topic but I'm struggling a bit with the same scenario having the
IndexError: index 0 is out of bounds for axis 0 with size 0error.I'll paste the snippet of code here. Basically the data source comes from a
pandas Seriescoming from a DataFrame which has been converted intonp.arrayin order to avoid the error.Not sure why. I've tried to convert the data into arrays via few methods like the one in the example, the
.values,np.asarray, etc and still giving the same error. Basically what I'm tring to get is the SBIC and AIC for the series as you can imagine.The version is
statsmodels 0.13.2.If you can give a hand with this would be really appreciated. As said, not sure if it is me doing something wrong or is a general issue.
Thanks in advance guys.
Input:
Output: