3

I'm trying to retrieve an out-of-sample prediction for ARIMA model. However, I constantly receive errors and I'm not sure how should I proceed now:( The code is the following:

    from statsmodels.tsa.arima_model import ARIMA
    fit = ARIMA(endog, (1,1,1)).fit()
    params = fit.params
    forecast = fit.predict(params.all(), start='2015-9-21', end='2016-9-21', typ='levels')

It worked well (i.e. giving me a result, but not an out-of-sample one...) when I only used

    forecast = fit.predict(params.all(), typ='levels')

but when I added "start" and "end" dates (or only "start") it doesn't want to work, I constantly get errors. In case of the first cited chunk of code its: "TypeError: predict() got multiple values for keyword argument 'start'". I also tried with datetime type and it also didn't work. Can anyone help me with it?

3
  • There were several fixes for this since 0.6. For example end datetime wasn't supported github.com/statsmodels/statsmodels/issues/2587 I don't remember any problems with start date. However, the problem might be that the predict method of the results instance doesn't have params as an argument. try fit.predict(start='2015-9-21', end='2016-9-21', typ='levels') Commented Sep 23, 2015 at 16:53
  • 3
    Hello! Thank you for a tip - I tried without params as an argument and this time got error "AttributeError: 'NoneType' object has no attribute 'get_loc' " :( Commented Sep 25, 2015 at 8:17
  • 2
    @MBseekingforhelp do you get the answer already? I got "AttributeError: 'NoneType' object has no attribute 'get_loc' " too Commented Oct 17, 2017 at 6:46

2 Answers 2

0

I was getting a similar error to the one reported above:

"AttributeError: 'NoneType' object has no attribute 'get_loc' "

But I realised this was because I was passing an array (or list) without a datetime index, e.g. if you use pandas dataframes and input it as df.values, then you drop the time index, and ARMA doesn't have the dates information (so dates is None) which triggers this error. I suggest you feed in a pd.DataFrame or pd.Series object with a datetime index. See also this thread http://pystatsmodels.narkive.com/rhX3T509/arma-predict-throws-attributeerror-with-start-and-end-dates

Sign up to request clarification or add additional context in comments.

Comments

0

You can use

fit.forecast(steps, exog=None, alpha=0.05)

where steps=365 according to your start and end parameter if its on monthly basis. Refer to the this answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.