Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Statsmodels SARIMAX: How can I deal with the maxlag error?

I am trying to predict a seasonal time series using SARIMAX. The time series consits of daily maximum values for PV-feed-in, which leads to the assumption of a 365 day periodicity.

Here is my code:

mod= SARIMAX(realy.Max, order=(0,1,1), seasonal_order=(0,1,1,365))
results_SARIMAX = mod.fit(disp= -1)

I set s in seasonal_order to 365 because of my periodicity. Also I set the variables p,d,q, respectively P,D,Q according to some pre-considerations. My problem is, that after executing the code the following error is drawn:

ValueError: maxlag should be < nobs

When I set the value for s down from 365 to i.e. 150 it is working, but the result is bad, since this isn't my seasonality at all. The question is, where are maxlag or nobs defined and am I able to change them accordingly?

The docstring of the SARIMAX function is only telling about quaterly or monthly data and not daily data. Does someone has experience in working with SARIMAX and already did predictions with a time series based on daily values? I've scoured the internet for solving the problem, but I cannot find anything helpful.

Similar questions already came up here How to set maxlag when Forecasting Sales for smaller data in SARIMAX? and here How to change maxlag for ARMAX.predict?

But I don't understand how to overcome this problem in my case, since I don't have any exogenous values to commit.

I also built a model based on ARIMA with which I am able to do proper predictions. Since I'm not having a non-seasonal time series, I thought it might be a good idea to use SARIMAX for getting even better results. Unfortunately, I'm not able to deal with this error.

Thanks for your help in advance!

like image 706
carlsberg Avatar asked Mar 09 '17 17:03

carlsberg


1 Answers

You need several years (full seasonal cycles) to be able to estimate the seasonal part of a SARIMAX, see https://github.com/statsmodels/statsmodels/issues/3529 .

As an alternative you could use a spline or fourier series to model the seasonal pattern as exog. See for example http://robjhyndman.com/hyndsight/longseasonality/

Here is a draft notebook that uses patsy formula to create a seasonal spline for OLS and ARMA. SARIMAX will work in the same way. https://gist.github.com/josef-pkt/1ea164439b239b228557

like image 100
Josef Avatar answered Nov 07 '22 15:11

Josef