Reputation: 3937
I am struggling to understand how exactly to use ARIMA
within statsmodels
.
I am trying to fit an ARIMA model to a set of data I have and am using the same idea as in the answer to this question.
But, I don't know what my endog
values, which are the explanatory variables, need to be.
My code is as follows and I get the error:
TypeError: objfunc() takes exactly 2 arguments (20 given)
in the line:
brute(objfunc, grid, args=(opening_price), finish=None)
I am just passing it the 20 data points I have for this time series and am confused what it expects since this is not right.
def objfunc(order, endog):
fit = ARIMA(endog, order).fit()
return fit.aic()
from scipy.optimize import brute
grid = (slice(1, 3, 1), slice(1, 3, 1), slice(1, 3, 1))
brute(objfunc, grid, args=(opening_price), finish=None)
Upvotes: 3
Views: 84
Reputation: 114976
The following might be a solution. You should really include enough code so that it can be copied and run to reproduce the problem.
In the call to brute
, change args=(opening_price)
to args=(opening_price,)
. You don't show what opening_price
is, but I assume it is a sequence, and when you write args=(opening_price)
(which is equivalent to args=opening_price
), the elements of opening_price
are expanded into separate arguments when passed to objfunc
. The correct form, args=(opening_price,)
, ensures that args
is a tuple containing a single element, opening_price
.
Upvotes: 2