Explosive forecast when using MAdM (ETSModel)

Open
#8,551 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
matplotlib, numpy, pandas, python
Domain
data

Research direction

Run the provided Python example using ETSModel with the supplied time series and compare the 12-step forecast with the attached plot. Investigate the MAdM configuration, fitted values, and forecast behavior to determine whether the explosive result is expected or indicates a bug; done means explaining the behavior or identifying a reproducible correction.

Written by the indexing model from the issue text.

Description

comp-tsa type-bug
Describe the bug

Hello, this may not be a bug but I need help trying to understand the behaviour of this specific model on this specific time series.
I currently try several ETS models and choose the one with the minimal AICc. For this time series, the MAdM method is chosen.

Code Sample, a copy-pastable example if possible
import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    from statsmodels.tsa.exponential_smoothing.ets import ETSModel

    endog = np.array(
        [
            52.0,
            250.43,
            261.01,
            265.0,
            56.77,
            16.0,
            50.09,
            65.0,
            21.0,
            89.5,
            20.0,
            1.0,
            123.0,
            84.0,
            91.0,
            163.0,
            16.0,
            27.0,
            78.5,
            38.0,
            61.0,
            5.0,
            82.0,
            15.0,
        ]
    )

    fit = ETSModel(
        endog,
        error='mul',
        trend='add',
        seasonal='mul',
        damped_trend=True,
        seasonal_periods=12,
        initialization_method='heuristic',
    ).fit(full_output=False, disp=False)

    plt.plot(endog, label='Demand history')
    plt.plot(fit.fittedvalues, label='Fitted values')
    plt.plot(
        pd.Series(fit.forecast(12), index=range(24, 36)), label='Forecasted values'
    )
    plt.legend(loc='upper left')

I've added a simple plot to showcase the forecast results.
Explosive_Forecast

Let me know if you need anything else to be able to explain why this behaviour occurs.

Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

Note: Please be sure you are using the latest released version of statsmodels, or a recent build of main. If your problem has been fixed in an unreleased version, you might be able to use main until a new release occurs.

Note: If you are using a released version, have you verified that the bug exists in the main branch of this repository? It helps the limited resources if we know problems exist in the current main branch so that they do not need to check whether the code sample produces a bug in the next release.

If the issue has not been resolved, please file it in the issue tracker.

Expected Output

A clear and concise description of what you expected to happen.

Output of import statsmodels.api as sm; sm.show_versions()

[paste the output of import statsmodels.api as sm; sm.show_versions() here below this line]
INSTALLED VERSIONS

Python: 3.9.12.final.0

statsmodels

Installed: 0.13.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\statsmodels)

Required Dependencies

cython: 0.29.32 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\Cython)
numpy: 1.22.3 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\numpy)
scipy: 1.7.3 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\scipy)
pandas: 1.4.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\pandas)

dateutil: 2.8.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\dateutil)

patsy: 0.5.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\patsy)

Optional Dependencies

matplotlib: 3.5.1 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\matplotlib)
backend: QtAgg
cvxopt: Not installed
joblib: 1.1.0 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\joblib)

Developer Tools

IPython: 8.4.0 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\IPython)
jinja2: 3.0.3 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\jinja2)
sphinx: Not installed
pygments: 2.11.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\pygments)
pytest: 7.1.2 (C:\Users\user\miniconda3\envs\development_FE\lib\site-packages\pytest)

virtualenv: Not installed

Dominant language
Python
Stars
11.6k
Forks
3.6k
Avg merge
7h 37m
Merged PRs (30d)
96

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statsmodels/statsmodels

All issues in statsmodels/statsmodels

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.