0

I tried to train an arima model, but I got this error.

ValueError: Encountered exception in stationarity test ('adf'). This can occur in seasonal 
settings when a large enough `m` coupled with a large enough `D` difference the training 
array into too few samples for OLS (input contains 7 samples). Try fitting on a larger 
training size (raised from LinAlgError: Singular matrix)

Here is my code:

auto_model = pm.auto_arima(
            train_data.Qty,
            start_p=1,
            start_q=1,
            test='adf',
            max_p=3,
            max_q=3,
            m=1,
            d=None,
            seasonal=False,
            start_P=0,
            D=0,
            trace=True,
            error_action="ignore",
            suppress_warnings=True,
            stepwise=True,
            return_valid_fits=False,
        )
p = 1
d = 1
q = 1
arima_order = (p, d, q)
auto_model_fit = auto_model.fit(train_data.Qty)
auto_predict = auto_model_fit.predict(n_periods=CS.PREDEICT_MONTHS)
model = sm.tsa.SARIMAX(train_data.Qty, trend='c', order=arima_order,enforce_stationarity=False, enforce_invertibility=False)
# model = ARIMA(train_data.Qty, order=(p, d, q))
model_fit = model.fit()

adjust_pre = model_fit.predict(start=0, end=30, dynamic=False)
adjust_pre.drop(index=0, inplace=True)
adjust_pre.reset_index(drop=True, inplace=True)

The training data is sale of 24 months, length of training size is 24, and I want to predict sales value of next 6 months, but I got the error above. Could anyone help me fix this?

ddd
  • 41
  • 4

1 Answers1

0

I had the same issue, and found that adf as a stationarity test gives some weird errors. You can try kpss as the test as test='kpss'.

A Newbie
  • 113
  • 8
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 17 '22 at 18:12