Max lag problem using auto arima function

905 Views Asked by At

I am trying to run an stepwise analysis using auto arima function for different products. All my products have monthly data from january 2019, till December 2021 (36 data points). Nevertheless, I am using a training set till June 2021, therefore 30 points for training and then 6 points for testing. With almost all of my products I can perform the auto arima analysis without any problem, but for some of them I am having a problem if I set m=12 (because is monthly data). Here is the code that I am using:

step_wise=auto_arima(y=train[train['CTN']=='HX9004/10']['Quantity Adjusted'],
X=train[train['CTN']=='HX9004/10']['Price'].values.reshape(1, -1).transpose(),
start_p=0,
start_q=0,
start_P=0,
start_Q=0,
seasonal=True,
m=12,
test='kpss',
trace=True, 
error_action='ignore', 
suppress_warnings=True, 
stepwise=False)

The formula train[train['CTN']=='HX9004/10']['Quantity Adjusted'] simply gives me the sales per month of that specific product (CTN). Below is the error I am having with some of my products:

ValueError: All lag values up to 'maxlag' produced singular matrices. Consider using a longer series, a different lag term or a different test.

Here are some screenshot of the data I am using in that function:

Sales Prices

Any help would be much appreciated. I wouldn't like to run some products setting m=12 and others without setting it.

Thanks!

1

There are 1 best solutions below

0
On

The issue seems to be contained in the type of test used to determine seasonality. By default, the seasonal_test parameter is set to 'ocsb' and can throw the maxlag error. Try changing this to 'ch', i.e.

seasonal_test = 'ch'