def step_ARIMA(resid, p_max, d_max, q_max): from statsmodels.tsa.arima_model import ARIMAResults from statsmodels.tsa.arima_model import ARIMA best_BIC = 9999999999999999.0 for p in range(p_max + 1): for d in range(d_max + 1): for q in range(q_max + 1): if(p > 0 or q > 0): try: order = (p, d, q) BIC, order, model = model_ARIMA_2(resid, order) if(BIC < best_BIC): best_model = model best_BIC = BIC best_order = order except: pass return(best_BIC, best_order, best_model)