Two things:
With ADF, what you do is to test both the null of a unit root against a stationary process as well as against an explosive process, i.e., in a model like $y_t=\rho y_{t-1}+\epsilon_t$, that $\rho=1$ against $|\rho|<1$ or against $\rho>1$.
There is no reason whatsoever that inability to reject a null against an alternative in one direction should automatically imply that we will be able to reject in the opposite direction. This is not specific to unit root tests at all: it is perfectly possible that the data is not sufficiently informative to reject the null that a regression coefficient is zero against a positive or against a negative coefficient.
With KPSS you are not looking at the same types of alternatives. Instead, you are using two different specifications for the deterministic trend part of the process, level and trend. You first test the null that the process is stationary around some constant mean, and in the second case, that the process is stationary around some time trend.
I didn't try to replicate the problems with gretl but at least the R packages you mention seem to agree if both the deterministics (trend vs. constant aka drift vs. none) and the lags (fixed, information criteria, heuristics) are specified in the same way. There are differences in the way the p-values are computed but for the data x
you generated they are very similar.
I have written the overview below for my students and thought I could share it here if someone finds it useful. Personally, I mostly used tseries
and CADFtest
:
adf.test()
in tseries
.
Deterministics: Linear trend only.
Lags: Heuristic by default, but can be selected by the user.
P-value: From critical value table.
CADFtest()
in CADFtest
.
Deterministics: Trend by default, constant (aka drift) or none also supported.
Lags: Default is 1 but can be selected via information criteria or by the user.
P-value: Computation based on Costantini et al. (2007). See also Lupi (2009). Unit Root CADF Testing with R. Journal of
Statistical Software, 32 (2), 1-19. http://www.jstatsoft.org/v32/i02/.
Comments: Additional regressors (and their lags) can be added to auxiliary
regression.
ur.df()
in urca
.
Deterministics: None by default, constant and trend also supported.
Lags: Default is 1, but can be selected via information criteria or by the user.
P-value: None, but summary()
reports critical value table (1%, 5%, 10%).
adfTest()
in fUnitRoots
.
Deterministics: None by default, constant and trend also supported.
Lags: Default is 1, but can be selected by the user.
P-value: From critical value table.
Comments: Based on adf.test()
from tseries
but extended by
additional deterministics.
For the data you had generated:
set.seed(1)
x <- rnorm(50, 0, 3)
Let's look at the different results for the test with trend (because this is supported by all functions) and 10 lags (as suggested by your heuristic above). The test statistics is always exactly the same and the p-values are close.
tseries::adf.test(x, k = 10)
## Augmented Dickey-Fuller Test
##
## data: x
## Dickey-Fuller = -1.6757, Lag order = 10, p-value = 0.7044
## alternative hypothesis: stationary
library("CADFtest")
CADFtest(x, max.lag.y = 10, type = "trend")
## ADF test
##
## data: x
## ADF(10) = -1.6757, p-value = 0.743
## alternative hypothesis: true delta is less than 0
## sample estimates:
## delta
## -1.751283
urca::ur.df(x, lags = 10, type = "trend")
## ###############################################################
## # Augmented Dickey-Fuller Test Unit Root / Cointegration Test #
## ###############################################################
##
## The value of the test statistic is: -1.6757 1.3699 2.0189
fUnitRoots::adfTest(x, lags = 10, type = "ct")
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 10
## STATISTIC:
## Dickey-Fuller: -1.6757
## P VALUE:
## 0.7044
##
## Description:
## Sat Aug 22 20:19:18 2015 by user: zeileis
Best Answer
These are two different questions. According to the tag description of a unit root,
According to the tag description of autocorrelation,
Some differences between the Ljung-Box (LB) and the Durbin-Watson (DW) tests
*It is enough that $e_t$ is a stationary process or an I(0) process which are almost the same.