Applies multiple unit root and stationarity tests to a time series, providing an integrated assessment of persistence properties. Implements Augmented Dickey-Fuller (ADF), Elliott-Rothenberg-Stock (ERS), Kwiatkowski-Phillips-Schmidt-Shin (KPSS), and Phillips-Perron tests.
test_unit_root(y, max_lags = NULL, significance_level = 0.05, verbose = FALSE)A list of class "signaly_unitroot" containing:
Results from ADF tests (none, drift, trend specifications)
Results from ERS tests (DF-GLS and P-test)
Results from KPSS tests (level and trend)
Results from Phillips-Perron tests
Data frame summarizing all test results
Integrated conclusion about stationarity
Classification: stationary, trend-stationary, difference-stationary, or inconclusive
Numeric vector of the time series to test.
Maximum number of lags for ADF-type tests. If NULL,
defaults to floor(12 * (length(y)/100)^0.25).
Significance level for hypothesis testing. Default is 0.05.
Logical indicating whether to print detailed results.
The function synthesizes results using the following logic:
If ADF/ERS reject unit root AND KPSS fails to reject stationarity: Series is likely stationary
If ADF/ERS fail to reject AND KPSS rejects stationarity: Series likely has unit root (difference-stationary)
If only trend-ADF rejects: Series is likely trend-stationary
Conflicting results indicate inconclusive or structural breaks
The battery of tests addresses different null hypotheses and specifications:
Augmented Dickey-Fuller (ADF) tests the null of a unit root against the alternative of stationarity. Three specifications are tested:
none: No constant, no trend (random walk)
drift: Constant included (random walk with drift)
trend: Constant and linear trend
Elliott-Rothenberg-Stock (ERS) tests provide more power than ADF by using GLS detrending. Two variants:
DF-GLS: GLS-detrended Dickey-Fuller test
P-test: Point-optimal test
KPSS reverses the hypotheses: null is stationarity, alternative is unit root. This allows testing the stationarity hypothesis directly.
Phillips-Perron uses non-parametric corrections for serial correlation, avoiding lag selection issues.
Dickey, D. A., & Fuller, W. A. (1979). Distribution of the Estimators for Autoregressive Time Series with a Unit Root. Journal of the American Statistical Association, 74(366), 427-431.
Elliott, G., Rothenberg, T. J., & Stock, J. H. (1996). Efficient Tests for an Autoregressive Unit Root. Econometrica, 64(4), 813-836.
Kwiatkowski, D., Phillips, P. C. B., Schmidt, P., & Shin, Y. (1992). Testing the null hypothesis of stationarity against the alternative of a unit root. Journal of Econometrics, 54(1-3), 159-178.
Phillips, P. C. B., & Perron, P. (1988). Testing for a unit root in time series regression. Biometrika, 75(2), 335-346.
ur.df, ur.ers,
ur.kpss, ur.pp
set.seed(123)
stationary <- arima.sim(list(ar = 0.5), n = 100)
result <- test_unit_root(stationary)
print(result$conclusion)
nonstationary <- cumsum(rnorm(100))
result2 <- test_unit_root(nonstationary)
print(result2$conclusion)
Run the code above in your browser using DataLab