Forecasting with ARIMA

217 views
Skip to first unread message

Ignacio Gago Padreny

unread,
Apr 26, 2015, 12:58:47 PM4/26/15
to pystat...@googlegroups.com
Hello,

I am currently involved in a project which involves detecting anomalies. For that, after modelling the system the idea is to forecast the next value and expect the next value to be very similar as the forecasted one.

For that i am using statsmodels. First i tried to use some datasets from pandas, use x13_arima_select_order for obtaining (p,d,q) values and after that use tsa.arima_model.ARIMA with those parameters. Well, after that i use .fit() for obtaining an ARIMAResult object and use .plot_predict(). I see that the forecasted values are very similar to the real ones, which is a good sign.

I have some doubts that i would much appreciate being solved. .fit() what does exactly do? And also, when using ARIMAResult.predict() i get the values in the ARIMA model, how can i get them in the original ts range? plot_predict() seems to forecast and also do that, but predict() doesn't.

Thanks in advance

Chad Fulton

unread,
Apr 27, 2015, 12:16:31 PM4/27/15
to Statsmodels Mailing List
On Sun, Apr 26, 2015 at 9:57 AM, Ignacio Gago Padreny <iga...@gmail.com> wrote:
> Hello,
>
> I am currently involved in a project which involves detecting anomalies. For
> that, after modelling the system the idea is to forecast the next value and
> expect the next value to be very similar as the forecasted one.
>
> For that i am using statsmodels. First i tried to use some datasets from
> pandas, use x13_arima_select_order for obtaining (p,d,q) values and after
> that use tsa.arima_model.ARIMA with those parameters. Well, after that i use
> .fit() for obtaining an ARIMAResult object and use .plot_predict(). I see
> that the forecasted values are very similar to the real ones, which is a
> good sign.
>
> I have some doubts that i would much appreciate being solved. .fit() what
> does exactly do?

.fit() estimates the parameters of the model, by default using maximum
likelihood estimation. If you google for ARIMA estimation, you will
get many results describing this procedure in detail.

> And also, when using ARIMAResult.predict() i get the values
> in the ARIMA model, how can i get them in the original ts range?
> plot_predict() seems to forecast and also do that, but predict() doesn't.

As far as I know, if you specify the model as a Pandas object with a
datetime index, predict should return a Pandas object with the
appropriate datetime index, even when forecasting. Is this not
happening for you? Perhaps you can post the code you're using, and
what you expect to happen.

Ignacio Gago Padreny

unread,
Apr 28, 2015, 4:15:05 AM4/28/15
to pystat...@googlegroups.com
>As far as I know, if you specify the model as a Pandas object with a
>datetime index, predict should return a Pandas object with the
>appropriate datetime index, even when forecasting. Is this not
>happening for you? Perhaps you can post the code you're using, and
>what you expect to happen.

I didn't notice there is an option with .predict() that is typ='levels', which is not the default value. If you use the method with typ='levels' then the prediction is in the original time series, if not the prediction returned is in the arima model.

Thanks!
Reply all
Reply to author
Forward
0 new messages