Skip to contents

Runs an Augmented Dickey-Fuller test (H0: unit root / non-stationary; regression with drift, augmentation lag chosen by AIC from lags = 1, i.e. one lagged difference), a KPSS test (H0: level stationary; Bartlett kernel with the "short" truncation lag \(\lfloor 4 (n/100)^{1/4} \rfloor\)), plus a Ljung-Box autocorrelation test, and suggests a differencing order to achieve stationarity of the mean. Both unit-root tests are computed natively and reproduce urca::ur.df(type = "drift", selectlags = "AIC") and urca::ur.kpss(type = "mu") (statistics and 5 percent critical values) exactly; no external package is used.

Usage

morie_ts_stationarity(x, max_d = 2L)

Arguments

x

A numeric series or morie_ts.

max_d

Maximum differencing to search for the suggestion.

Value

A morie_ts_stationarity list: adf, kpss (statistic + whether stationary at 5%), ljung_box p-value, and suggested_d.

Examples

set.seed(1)
morie_ts_stationarity(cumsum(rnorm(100)))$suggested_d
#> [1] 1