Hi everyone, I hope you are good! I have a questi...
# general
s
Hi everyone, I hope you are good! I have a question about statsforecast auto_arima: The documentation shows that we can execute auto_arima like this:
Copy code
fcst = 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)
👀 1
m
Thanks for your question. We will come back to you soon.
s
Thank you @Max (Nixtla)!
Hello @Max (Nixtla), do you have any updates on this? Thank you, and thank you for this amazing package!
m
@fede (nixtla) (they/them), could you provide an answer?
s
Hi, just as a follow up, I have found a quick way of doing this through the AutoARIMAProphet class! Thank you
f
Hi @Sean Nassimiha! Thank you for using
StatsForecast
. 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:
Copy code
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.
s
Thank you @fede!
p
hey, sorry for jumping on this thread. I was wondering if there’s a way to extract the p,q values picked by the model after fitting it? (using
StatsForecast
)