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
I have the sales input data for 2 years say for 2014-2015 from month 04(April)-12(Dec) and need to forecast the value for the year 2016.
In this case,i have only small amount of data say less than 50 rows.
For this i am getting the error "ValueError: maxlag should be < nobs" ,so i browsed and found that i need to set the lesser maxlag value,but have no clue where to set it.
Already tried setting it in fit(maxlag=intValue,ic='bic') but it is not getting assigned with the new value and again the same error.
Where i need to and how i should set it actually?
Please help.
Looking for your response.
This is the code i tried:
def test_final_output():
df = pd.read_csv('../../data/salesoneproduct.csv', index_col=0)
nobs=len(df)
df.index.name=None
df.reset_index(inplace=True)
start = datetime.datetime.strptime("2014-04-01", "%Y-%m-%d")
date_list = [start + relativedelta(months=x) for x in range(0,48)]
df['index'] =date_list
df.set_index(['index'], inplace=True)
df.index.name=None
df.columns= ['riders']
df['riders'] = df.riders.apply(lambda x: int(x)*100)
mod = sm.tsa.statespace.SARIMAX(df.riders, trend='n', order=(0,1,0), seasonal_order=(1,1,1,12)
results = mod.fit(ic='bic',maxlag=10)
start = datetime.datetime.strptime("2019-04-01", "%Y-%m-%d")
date_list = [start + relativedelta(months=x) for x in range(0,12)]
future = pd.DataFrame(index=date_list, columns= df.columns)
df = pd.concat([df, future])
df['forecast'] = results.predict(start = 48, end = 59, dynamic= True)
df[['riders', 'forecast']].ix[-24:].plot(figsize=(12, 8))
print (df.forecast/100)
Thanks for the bug report! In this case, the bug is that we don't give a more informative error message.
The problem here is that starting parameters for the numerical optimization procedure can't be computed for the model you're trying to fit because you have too few observations to perform conditional least squares (which is how we get starting parameters). In this case, there's nothing to be done but specify starting parameters yourself, for example you could do:
I should also note that the maxlag and ic parameters have no effect for the SARIMAX model.
As a final note - the model you're specifying is probably not going to give great results even if you get it to perform the fitting, since you have so little data. I think you have 21 observations, and your seasonal order is 12. That means you don't even have two complete seasons worth of data.
Why did you state that a model with 1-2 years of observations would not be performing great results?
I am trying to forecast retail sales/demand with SARIMAX using statsmodels. I received also the same error. How do I know which parameters should I be using?
Why did you state that a model with 1-2 years of observations would not be performing great results?
Just because you wouldn't have very many full seasons and you'd risk overfitting the model to a small number of datapoints. It's similar to why a regression with only a couple of observations may not provide very useful inference.
Is exactly two years of data usable for SARIMAX? If I have two complete seasons would I be able to proceed?
If that's all the data you have, then that's certainly better than nothing.
However, depending on your model, you may need more than two complete seasons to estimate the starting parameters. See my comments here: #4465 (comment)
This is the issue tracker for the Python package “statsmodels”. It seems
like you want to find some help with an R package, so I’m guessing you
would get more help asking on an R mailing list.
Hi Chad
i'm trying the dickey fuller test on yearly data and want to make it stationary but im unable to do it. i have applied that test on monthly and daily but getting an error while applying the ADF on yearly data which i'm going to use for my ARIMA model. your help will be much appreciated.
Hi @sbnbari can you make a new issue, since your question is about ADF and this issue is about SARIMAX.
Please also copy and paste the error you're receiving (from your screenshot, I can only see the top of the ValueError, but not the whole traceback), and also let us know the output of:
@ChadFulton I have the sales input data for 3 years say for 2015-2017 and need to forecast the value for the year 2018.
In this case,i have only data say less than 210
rows.
For this i am getting the error "ValueError: maxlag should be < nobs" ,so i browsed and found that i need to set the lesser maxlag value,but have no clue where to set it.
Activity
ChadFulton commentedon Dec 26, 2016
Thanks for the bug report! In this case, the bug is that we don't give a more informative error message.
The problem here is that starting parameters for the numerical optimization procedure can't be computed for the model you're trying to fit because you have too few observations to perform conditional least squares (which is how we get starting parameters). In this case, there's nothing to be done but specify starting parameters yourself, for example you could do:
I should also note that the
maxlagandicparameters have no effect for theSARIMAXmodel.As a final note - the model you're specifying is probably not going to give great results even if you get it to perform the fitting, since you have so little data. I think you have 21 observations, and your seasonal order is 12. That means you don't even have two complete seasons worth of data.
josef-pkt commentedon Jan 1, 2017
I reformatted the code in the description.
FAQ label because I don't know if there is anything to do.
denizn commentedon Apr 5, 2018
Hello Chad,
Why did you state that a model with 1-2 years of observations would not be performing great results?
I am trying to forecast retail sales/demand with SARIMAX using statsmodels. I received also the same error. How do I know which parameters should I be using?
Thank you,
Deniz.
denizn commentedon May 1, 2018
Is exactly two years of data usable for SARIMAX? If I have two complete seasons would I be able to proceed?
ChadFulton commentedon May 2, 2018
Just because you wouldn't have very many full seasons and you'd risk overfitting the model to a small number of datapoints. It's similar to why a regression with only a couple of observations may not provide very useful inference.
If that's all the data you have, then that's certainly better than nothing.
However, depending on your model, you may need more than two complete seasons to estimate the starting parameters. See my comments here: #4465 (comment)
Chroa3 commentedon Nov 15, 2018
Some help to fix up these errors please?
Thanks in advance.
ChadFulton commentedon Nov 15, 2018
Chroa3 commentedon Nov 15, 2018
I´ll do that then, thanks a lot for your quick response Chad!
sbnbari commentedon Dec 18, 2018
Hi Chad

i'm trying the dickey fuller test on yearly data and want to make it stationary but im unable to do it. i have applied that test on monthly and daily but getting an error while applying the ADF on yearly data which i'm going to use for my ARIMA model. your help will be much appreciated.
ChadFulton commentedon Dec 19, 2018
Hi @sbnbari can you make a new issue, since your question is about ADF and this issue is about SARIMAX.
Please also copy and paste the error you're receiving (from your screenshot, I can only see the top of the ValueError, but not the whole traceback), and also let us know the output of:
python -c "import statsmodels; print(statsmodels.__version__)"Thanks!
sbnbari commentedon Dec 19, 2018
thanks
check this link please
#5432
BUG: Limit lag length in adf
BUG: Limit lag length in adf
AtifKhan777 commentedon Nov 27, 2019
@ChadFulton I have the sales input data for 3 years say for 2015-2017 and need to forecast the value for the year 2018.

In this case,i have only data say less than 210
rows.
For this i am getting the error "ValueError: maxlag should be < nobs" ,so i browsed and found that i need to set the lesser maxlag value,but have no clue where to set it.