Python Forum

Full Version: arima model error in python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi
i am using the software PyCharm(2018.1) software to create ARIMA model in pyhthon
here is the model that i have created:

def arima_Model_Static_PlotErrorAC_PAC(series, arima_order): 
    # prepare training dataset                               
    X = series  # print(X)    exit()
    train_size = int(len(X) * 0.50)  # 0.50
    train, test = X[0:train_size], X[train_size:]
    history = [x for x in train]     # make predictions    print(len(history))     print(history)     exit()
    errorList=list()
    expected= list()
    predictions = list()
    obs = list()
   
    for t in range(len(test)):
        model = ARIMA(history, order=arima_order) #exit()
        model_fit = model.fit(disp=False, transparams=False)
        yhat = model_fit.forecast()[0] #model_fit.forecast()[0] exit()
        predictions.append(yhat)
        obs = test[t]   
        history.append(obs) 
        expected.append(obs)
        errorResidualExpePred = obs - yhat 
        errorList.append(errorResidualExpePred)
        print('epoch=%i, predicted=%f, expected=%f' % (t, yhat, obs))

    mse = mean_squared_error(test, predictions)
    rmse = sqrt(mse)   
    print(model_fit.summary())
    print(rmse)
    return errorList
i called this model as follow:
series=np.array(diffARIMA)
#series=colDataSet
arima_order=(11,0,32)
outputResidualError=arima_Model_Static_PlotErrorAC_PAC(series, arima_order)
also the values of p, d, q are well chosen by applying the following rules
  • remove the seasonality
    • p: lag value where PACF cuts off first, so p=11.
    • d=0 because apply the ADF test test and found my series is stationary so no differentiate has been done
    • q: lag value where ACF chart crosses the upper confidence interval first, so q=32
.

the error that i have got when i run the model:
Error:
File "C:/109_personel/112_pyCharmArima/Presentation.py", line 296, in arima_Model_Static_PlotErrorAC_PAC model_fit = model.fit(disp=False, transparams=False) File "C:\109_personel\112_pyCharmArima\venv\lib\site-packages\statsmodels\tsa\arima_model.py", line 946, in fit start_ar_lags) File "C:\109_personel\112_pyCharmArima\venv\lib\site-packages\statsmodels\tsa\arima_model.py", line 562, in _fit_start_params start_params = self._fit_start_params_hr(order, start_ar_lags) File "C:\109_personel\112_pyCharmArima\venv\lib\site-packages\statsmodels\tsa\arima_model.py", line 541, in _fit_start_params_hr raise ValueError("The computed initial AR coefficients are not " ValueError: The computed initial AR coefficients are not stationary You should induce stationarity, choose a different model order, or you can pass your own start_params.
Finally i would like to mention that if a apply my model by selecting the following arima order
arima_order=(11,0,0)
arima_order=(0,0,16)
my modele is well executed

any help will be appreciated

Thank you