You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
STLForecastResults.get_prediction() with ETSModel as model fails when "trend"="mul" in the model kwargs #7309
I get an error when calling the get_prediction() method on a STLForecastResults object that is the output of STLForecast(endog=data, model=ETSModel, model_kwargs={'trend': 'mul'}).fit()
import pandas as pd
import numpy as np
df1 = pd.read_csv('...l//airline_passengers.csv',index_col='Month',parse_dates=True)
df1.index.freq = 'MS'
#STLForecast
from statsmodels.tsa.forecasting.stl import STLForecast
from statsmodels.tsa.exponential_smoothing.ets import ETSModel
stlf1 = STLForecast(df1, ETSModel)
stlf_res=stlf1.fit()
forecast1 = stlf_res.forecast(12) ----> If i Do forecast its working
forecast1
stlf2 = STLForecast(df1, ETSModel)
stlf_res2=stlf2.fit()
forecast2 = stlf_res.get_prediction()
forecast2 ----> Its giving error like below:
Exception: Data must be 1-dimensional
I am getting the same error; the get_prediction method is the one causing the problem.
The error has nothing to do with the df1, since it works perfectly fine before calling the .forecast(12)
I gave it a start and enddate like and i also get the 1 dimensional error. Am i doing something wrong ? I am not even inputting arrays.
Hi @bashtage, it looks like the 1-dimenional error is still there in 0.13 for STLForecast. Any way to work around this issue to get prediction intervals from an STLForecast.fit().forecast()?
Sorry @bashtage I just found out that the issue turns up when I use a one-column dataframe with a datetime index as opposed to a series with a datetime index. So this is not an issue anymore. Thank you for your response :)
Activity
AnupamPandey1924 commentedon Mar 3, 2021
Stlf_model = STLForecast( ts, model =ARIMA, model_kwargs ={ 'order': (2,1,0)}, period =52)
Stlf_model = Stlf_model.fit()
Stlf_model.get_prediction() gives the following error
' Data must be 1-dimensional'
However, Stlf_model.forecast() runs fine.
But I need to get the corresponding confidence interval of the forecasted values
bashtage commentedon Mar 3, 2021
Can you provide a complete, copy-pastable example that reproduces?
AnupamPandey1924 commentedon Mar 3, 2021
Hi,
I am using the following code (data attached)
import pandas as pd
from statsmodels.tsa.forecasting.stl import STLForecast
from statsmodels.tsa.arima.model import ARIMA
ts = pd. read_csv('../ts_example.csv')
ts = ts.set_index('Date')
ts = ts.resample('W-SUN').interpolate(method='linear')
ts = ts.sort_index()
stlf_model = STLForecast(endog=ts,model = ARIMA,model_kwargs= { 'order':(2,1,0)}, period = 52)
stlf_model = stlf_model.fit()
forecast = stlf_model.forecast(26)
stlf_model.get_prediction() —- throws an error
ts_example.zip
BUG: Fix STLForecast when start is None
BUG: Correct ETS simulation and forecast error variance
BUG: Correct ETS simulation and forecast error variance
rashmisoni20 commentedon Jun 25, 2021
Hi,
I am trying to run below code, but getting error:
import pandas as pd
import numpy as np
df1 = pd.read_csv('...l//airline_passengers.csv',index_col='Month',parse_dates=True)
df1.index.freq = 'MS'
#STLForecast
from statsmodels.tsa.forecasting.stl import STLForecast
from statsmodels.tsa.exponential_smoothing.ets import ETSModel
stlf1 = STLForecast(df1, ETSModel)
stlf_res=stlf1.fit()
forecast1 = stlf_res.forecast(12) ----> If i Do forecast its working
forecast1
stlf2 = STLForecast(df1, ETSModel)
stlf_res2=stlf2.fit()
forecast2 = stlf_res.get_prediction()
forecast2 ----> Its giving error like below:
Exception: Data must be 1-dimensional
can somebody help?
bashtage commentedon Jun 25, 2021
Sounds pretty clear.
df1needs to be 1 dimensional. You can only process 1 series at a time.AndreasDL commentedon Aug 30, 2021
I am getting the same error; the get_prediction method is the one causing the problem.
The error has nothing to do with the df1, since it works perfectly fine before calling the .forecast(12)
I gave it a start and enddate like and i also get the 1 dimensional error. Am i doing something wrong ? I am not even inputting arrays.
bashtage commentedon Aug 31, 2021
Can you post a complete demo of the issue? Are you using master or 0.12.2?
kidusasfaw commentedon Jun 20, 2022
Hi @bashtage, it looks like the 1-dimenional error is still there in 0.13 for STLForecast. Any way to work around this issue to get prediction intervals from an STLForecast.fit().forecast()?
bashtage commentedon Jun 20, 2022
@kidusasfaw Can you post some code to show this issue?
kidusasfaw commentedon Jun 20, 2022
Sorry @bashtage I just found out that the issue turns up when I use a one-column dataframe with a datetime index as opposed to a series with a datetime index. So this is not an issue anymore. Thank you for your response :)