mojolearn.select_d#

mojolearn.select_d(y, D=0, s=0, d_max=None, pval_threshold=0.05)[source]#

Choose the differencing order d for each series by the KPSS test.

Runs kpss_test() for d = 0, 1, ..., d_max - 1 and returns, per series, the first order at which it tests stationary, or d_max if none does. This is the d step of cuML’s AutoARIMA.search. The seasonal order D is not chosen: pass the one you want. Input layout and non-finite handling are as for kpss_test().

Parameters:
  • y (array-like of shape (n_obs, n_series) or (n_obs,)) – The series, one per column.

  • D (int, default 0) – Seasonal differencing applied before the test.

  • s (int, default 0) – Seasonal period.

  • d_max (int or None, default None) – Largest d returned; None means 2 - D. Must satisfy 0 <= d_max <= 2 - D.

  • pval_threshold (float, default 0.05) – Significance level of the KPSS test.

Returns:

Array of shape (n_series,), int32

Examples

>>> import numpy as np, mojolearn
>>> y = np.random.default_rng(0).standard_normal((200, 4)).cumsum(axis=0).astype(np.float32)
>>> np.asarray(mojolearn.select_d(y)).shape
(4,)