unitroot_ndiffs: Number of differences required for a stationary series

View source: R/features.R

unitroot_ndiffsR Documentation

Number of differences required for a stationary series

Description

Use a unit root function to determine the minimum number of differences necessary to obtain a stationary time series.

Usage

unitroot_ndiffs(
  x,
  alpha = 0.05,
  unitroot_fn = ~unitroot_kpss(.)["kpss_pvalue"],
  differences = 0:2,
  ...
)

unitroot_nsdiffs(
  x,
  alpha = 0.05,
  unitroot_fn = ~feat_stl(., .period)[2] < 0.64,
  differences = 0:2,
  .period = 1,
  ...
)

Arguments

x

A vector to be tested for the unit root.

alpha

The level of the test.

unitroot_fn

A function (or lambda) that provides a p-value for a unit root test.

differences

The possible differences to consider.

...

Additional arguments passed to the unitroot_fn function

.period

The period of the seasonality.

Details

Note that the default 'unit root function' for unitroot_nsdiffs() is based on the seasonal strength of an STL decomposition. This is not a test for the presence of a seasonal unit root, but generally works reasonably well in identifying the presence of seasonality and the need for a seasonal difference.

Value

A numeric corresponding to the minimum required differences for stationarity.


feasts documentation built on Sept. 30, 2024, 9:14 a.m.