Skip to main content

num_seas_diffs

num_seas_diffs(x, season_length, max_d=1)
Determine the optimal number of seasonal differences for stationarity. Uses a seasonal strength heuristic based on STL decomposition to determine if seasonal differencing is needed. The function applies seasonal differencing iteratively until the seasonal strength falls below the threshold or the maximum number of differences is reached. Parameters:
NameTypeDescriptionDefault
xndarrayArray with the time series.required
season_lengthintLength of the seasonal pattern.required
max_dintMaximum number of differences to consider. Defaults to 1.1
Returns:
NameTypeDescription
intintOptimal number of seasonal differences.

num_diffs

num_diffs(x, max_d=1)
Determine the optimal number of non-seasonal differences for stationarity. Uses the KPSS (Kwiatkowski-Phillips-Schmidt-Shin) test to determine how many times the series needs to be differenced to achieve stationarity. The function applies differencing iteratively until the KPSS statistic falls below the threshold or the maximum number of differences is reached. Parameters:
NameTypeDescriptionDefault
xndarrayArray with the time series.required
max_dintMaximum number of differences to consider. Defaults to 1.1
Returns:
NameTypeDescription
intintOptimal number of differences.

diff

diff(x, d)
Subtract previous values of the series Parameters:
NameTypeDescriptionDefault
xndarrayArray with the time series.required
dintLag to subtractrequired
Returns:
TypeDescription
ndarraynp.ndarray: Differenced time series.