Sean Nassimiha
06/21/2022, 2:02 PMfcst = StatsForecast(
series_train,
models=[(auto_arima, 12)],
freq='M',
n_jobs=1
)
But what if I want to restrict the search space of the AR, MA orders? How can I limit the order of (S)AR and (S)MA to, say, p=1, q=1, P=1, Q=1?
Thank you! (please let me know if I should be asking this in some other channel)Max (Nixtla)
06/21/2022, 2:14 PMSean Nassimiha
06/21/2022, 2:14 PMMax (Nixtla)
06/22/2022, 2:36 PMSean Nassimiha
06/22/2022, 3:09 PMfede (nixtla) (they/them)
06/22/2022, 3:21 PMStatsForecast
. For the moment, those parameters can’t be modified (we are working on this). There is a workaround though: the auto_arima
function uses auto_arima_f
. So you can create your own auto_arima
function using:
from statsforecast.arima import auto_arima_f, forecast_arima
def auto_arima(X: np.ndarray, h: int, future_xreg=None, season_length: int = 1,
approximation: bool = False, level: Optional[Tuple[int]] = None) -> np.ndarray:
y = X[:, 0] if X.ndim == 2 else X
xreg = X[:, 1:] if (X.ndim == 2 and X.shape[1] > 1) else None
mod = auto_arima_f(
y,
xreg=xreg,
period=season_length,
approximation=approximation,
allowmean=False, allowdrift=False, #not implemented yet
##EXTRA PARAMETERS HERE
max_p=1,
max_q=1
)
fcst = forecast_arima(mod, h, xreg=future_xreg, level=level)
if level is None:
return fcst['mean']
return {
'mean': fcst['mean'],
**{f'lo-{l}': fcst['lower'][f'{l}%'] for l in reversed(level)},
**{f'hi-{l}': fcst['upper'][f'{l}%'] for l in level},
}
Then, you can pass your auto_arima
to the models
argument.Sean Nassimiha
06/23/2022, 6:52 AMPandula
06/23/2022, 1:25 PMStatsForecast
)