def model_ARIMA(ts, order): from statsmodels.tsa.arima_model import ARIMA # statsmodel package since version 0.8 strongly recommends to set start_ar_lags. # So added it here. Also altered the code to make it robust against compute problems. try: model = ARIMA(ts, order = order) model_fit = model.fit(disp=0, method='mle', trend='nc', start_ar_lags=7, ) print(model_fit.summary()) return(model_fit) except ValueError: print('This model does not properly compute!') ar2_model = model_ARIMA(ts_series_ar2, order = (2,0,0))