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

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, ... )

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 |

.period | The period of the seasonality. |

A numeric corresponding to the minimum required differences for stationarity.