Giter Club home page Giter Club logo

Comments (6)

jmoralez avatar jmoralez commented on May 16, 2024 1

Hi @asinig. The StatsForecast class is designed to be used only in forecasting, so it doesn't save anything related to training. However the implementation for the ARIMA model saves its residuals, so you can access them if you use it directly. Here's an example:

from statsforecast.arima import auto_arima_f
from statsforecast.utils import AirPassengers

mod = auto_arima_f(AirPassengers, period=12)
mod['residuals'][:5]
#  array([0.06466322, 0.03356584, 0.03380615, 0.02255185, 0.01075387])

Let us know if this helps.

from statsforecast.

jmoralez avatar jmoralez commented on May 16, 2024 1

Hi @asinig. Sorry, I agree we have to work on the documentation. What mod['arma'] returns is the same as defined here

arma
A compact form of the specification, as a vector giving the number of AR, MA, seasonal AR and seasonal MA coefficients, plus the period and the number of non-seasonal and seasonal differences.

So it is (p, q, P, Q, period, d, D). You may find the arima_string function (which returns ARIMA(p, d, q)(P, D, Q)[period]) useful as well:

from statsforecast.arima import arima_string, auto_arima_f
from statsforecast.utils import AirPassengers

mod = auto_arima_f(AirPassengers, period=12)
mod['arma']
# (1, 0, 0, 0, 12, 1, 1)
arima_string(mod)
# 'ARIMA(1,1,0)(0,1,0)[12]'

from statsforecast.

mergenthaler avatar mergenthaler commented on May 16, 2024

@all-contributors please add @asinig for idea

from statsforecast.

allcontributors avatar allcontributors commented on May 16, 2024

@mergenthaler

I've put up a pull request to add @asinig! 🎉

from statsforecast.

asinig avatar asinig commented on May 16, 2024

Hi @asinig. The StatsForecast class is designed to be used only in forecasting, so it doesn't save anything related to training. However the implementation for the ARIMA model saves its residuals, so you can access them if you use it directly. Here's an example:

from statsforecast.arima import auto_arima_f
from statsforecast.utils import AirPassengers

mod = auto_arima_f(AirPassengers, period=12)
mod['residuals'][:5]
#  array([0.06466322, 0.03356584, 0.03380615, 0.02255185, 0.01075387])

Let us know if this helps.

@jmoralez Thank you for the example and I apologize for the delay in responding. I'm struggling a bit to fully understand how it works, since most of the library implementation is not commented. I saw that auto_arima and auto_arima_f do the same thing, and I was able to derive the residuals. What I can't figure out is that mod['arma'] returns the SARIMA model orders but I can't figure out in what order. In the example above mod['arma'] is a tuple, specifically (1, 0, 0, 12, 1, 1) where
mod['coef'] = {'ar1': -0.30005076872006264}, so mod['arma'] returns a tuple representing the orders (p,d,q, ?, time horizon,?,?). I tried to figure out looking at the implementation in the arima.py file (line 729), but I still don't understand what the ? values represent, because in this case they can't be P,D,Q (the seasonal orders) otherwise I would have had the seasonal ma coefficient printed in mod['coef'].

Let me know please, thank you again

from statsforecast.

asinig avatar asinig commented on May 16, 2024

Hi @asinig. Sorry, I agree we have to work on the documentation. What mod['arma'] returns is the same as defined here

arma
A compact form of the specification, as a vector giving the number of AR, MA, seasonal AR and seasonal MA coefficients, plus the period and the number of non-seasonal and seasonal differences.

So it is (p, q, P, Q, period, d, D). You may find the arima_string function (which returns ARIMA(p, d, q)(P, D, Q)[period]) useful as well:

from statsforecast.arima import arima_string, auto_arima_f
from statsforecast.utils import AirPassengers

mod = auto_arima_f(AirPassengers, period=12)
mod['arma']
# (1, 0, 0, 0, 12, 1, 1)
arima_string(mod)
# 'ARIMA(1,1,0)(0,1,0)[12]'

this is clearer, thank you! @jmoralez

from statsforecast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.