Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seasonal naive confidence intervals are incorrect #903

Closed
andrewscottm opened this issue Sep 12, 2024 · 0 comments · Fixed by #932
Closed

seasonal naive confidence intervals are incorrect #903

andrewscottm opened this issue Sep 12, 2024 · 0 comments · Fixed by #932
Labels

Comments

@andrewscottm
Copy link
Contributor

What happened + What you expected to happen

The seasonal naive confidence interval for the last time in the forecasted horizon is used for all times.

k = np.floor((h - 1) / self.season_length)

Should be k = np.floor(np.arange(h) / self.season_length) as in the R version.

When the time horizon increases, the first forecasted time's confidence interval increases. It should be constant.

Versions / Dependencies

statsforecast 1.7.6
pandas 2.2.2
Python 3.11.9 (main, Apr 19 2024, 11:44:45) [Clang 14.0.6 ]
MacOS 14.6.1

Reproducible example

import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import SeasonalNaive

df = pd.DataFrame({
    'unique_id': '0',
    'ds': pd.date_range(start='2000-01-01', periods=10, freq='1D'),
    'y': [1., 4., 5., 5., 1., 4., 5., 5., 7., 3.]
})

m = StatsForecast(models=[SeasonalNaive(season_length=7)], freq='1D', n_jobs=1, verbose=True)
m.fit(df=df)
print(m.predict(h=1, level=[95]).iloc[0, :])
print(m.predict(h=8, level=[95]).iloc[0, :])
print(m.predict(h=15, level=[95]).iloc[0, :])

unique_id 0
ds 2000-01-11 00:00:00
SeasonalNaive 5.0
SeasonalNaive-lo-95 -1.093776
SeasonalNaive-hi-95 11.093776

unique_id 0
ds 2000-01-11 00:00:00
SeasonalNaive 5.0
SeasonalNaive-lo-95 -3.6179
SeasonalNaive-hi-95 13.6179

unique_id 0
ds 2000-01-11 00:00:00
SeasonalNaive 5.0
SeasonalNaive-lo-95 -5.554729
SeasonalNaive-hi-95 15.554729

Issue Severity

Medium: It is a significant difficulty but I can work around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant