Giter Club home page Giter Club logo

Comments (5)

jmoralez avatar jmoralez commented on June 18, 2024 3

Hey @Timuchin. That seems to be due to the default method ('CSS') of the arima function, by setting method='CSS-ML' (the default of statsforecast.models.ARIMA) I get the same result as in statsmodels.

The warnings seem to be coming from the suggestions of the optimization algorithm, which sometimes suggests values that produce Inf in the objective function. I think we can make that return a big float instead.

from statsforecast.

jmoralez avatar jmoralez commented on June 18, 2024

Hey @Timuchin, thanks for the excellent report. Are you still getting this error? I get it as a warning, i.e. RuntimeWarning: invalid value encountered in subtract df = fun(x) - f0

from statsforecast.

github-actions avatar github-actions commented on June 18, 2024

This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one.

from statsforecast.

Timuchin avatar Timuchin commented on June 18, 2024

@jmoralez Hello!
After updating statsforecast to 1.7.3 it stopped getting error. But yeah, it throws a warning. I guess the main reason that it cannot converge to stable solution.
RuntimeWarning: invalid value encountered in subtract df = fun(x) - f0
UserWarning: possible convergence problem: minimize gave code 2]

It does not seem as a big problem, though quite interesting that MA(1) from statsmodels does not get such error. I guess it successfully converges. As a result coefficient for MA(1) is different. And, what's more important, it calculates AIC criteria. This can can be important further for AutoARIMA.

param statsforecast statsmodels tsa statsmodels statespace
MA 0.911 0.975 0.975
intercept 91.29 91.71 91.71
AIC nan 7561.34 7561.34
from statsforecast.arima import arima
import numpy as np
import statsmodels.api as sm

np.random.seed(1234)

SIZE = 1_000
LOC = 1
SCALE = 1

eps = []

for i in range(SIZE):
    if i == 0:
        eps.append(np.random.normal(loc = LOC, scale = SCALE, size = 1)[0])
    elif (i > 0) & (i <= SIZE):
        eps.append(LOC + 0.99 * eps[i-1] + np.random.normal(loc = np.log(LOC), scale = np.sqrt(SCALE), size = 1)[0])

eps = np.array(eps)

ma_nixtla = arima(x = eps, order = (0, 0, 1))
ma_stats = sm.tsa.ARIMA(eps, order = (0, 0, 1)).fit()
ma_stats_ss  = sm.tsa.statespace.SARIMAX(eps, order = (0, 0, 1), trend='c').fit()

print(f'''
      MA coef are statsforecast:{ma_nixtla.get('coef').get('ma1')}, statsmodels tsa: {ma_stats.params[1]}, statsmodels statespace: {ma_stats_ss.params[1]}, \n
      Intercept coef are statsforecast:{ma_nixtla.get('coef').get('intercept')}, statsmodels tsa: {ma_stats.params[0]}, statsmodels statespace: {ma_stats_ss.params[0]}, \n
      AIC criteria are statsforecast:{ma_nixtla.get('aic')}, statsmodels tsa: {ma_stats.aic}, statsmodels statespace: {ma_stats_ss.aic}
      ''')
Dependencies

statsmodels==0.14.1

statsforecast==1.7.3

numpy==1.26.3

from statsforecast.

drewbitt avatar drewbitt commented on June 18, 2024

I am also seeing a ton of RuntimeWarning: invalid value encountered in subtract at df = fun(x) - f0

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.