SARIMAX model needs q, d, q, m parameters in order to operate properly.
- P stands for the order of AutoRegressive model and it can optically be estimated using PACF plot
- D stands for the number of differences for making a time series stationary and it can be estimated using the adfuller test while doing a loop of differences until it became stationary.
- Q stands for the order of MovingAverage model and it can optically be estimated using ACF plot.
- M stands for the number of periods indicating the seasonality and it can optically be estimated using the seasonal_decompose function.
Usually, a custom SARIMAX Grid CV like the following is able to find the optimum set of parameters.
p = range(min_series_p, max_series_p+1)
d = range(min_series_d, max_series_d+1)
q = range(min_series_q, max_series_q+1)
matrix = list(it.product(p, d, q))
pdq = [(x[0], x[1], x[2]) for x in matrix]
pdq_s = [(x[0], x[1], x[2], sts_series_s) for x in matrix]
for param in pdq:
for param_s in pdq_s:
if param[0] == param_s[0] and param[1] == param_s[1] and param[2] == param_s[2]:
mod = SARIMAX(ts.to_numpy(), order=param, seasonal_order=param_s)
model_fit = mod.fit(iprint=0, disp=0, method_kwargs={"warn_convergence": False})
I wonder if there is any way to extract programmatically the p, q, m values or even a range of them to reduce the Grid and therefore reduce the processing time for finding an optimum model order.
min_series_p = method()?
max_series_p = method()?
min_series_q = method()?
max_series_q = method()?
sts_series_m = method()?
Any ideas?