I am conducting unit root tests on the globtemp
dataset, which is clearly a series with a trend and some seasonality (not stationary). However, when applying the simple Dickey-Fuller test, the p-value I obtain is small, leading to the rejection of the null hypothesis and indicating that the series is stationary.
At the same time, performing the test using the augmented version (ADF), with R's default value for the number of lags used (k), the p-value does not reject the null hypothesis, indicating the non-stationarity of the time series. That said, I am very confused and do not understand this discrepancy. Why is it that, in the case of the simple DF test (k=0), the test fails to produce a realistic result? Moreover, if the test is this sensitive to the choice of "k", what is the best approach to take? Should we always rely on the default?
Additionally, I read that the presence of autocorrelation in the residuals violates the assumption of uncorrelated residuals in the test, potentially leading to incorrect results. Therefore, I also evaluated the presence of autocorrelation in the residuals of the first test (DF), and their behavior is consistent with that of white noise (I also tested this using Box-Ljung). This has left me even more confused about the inconsistent result mentioned above.
It's possible to check the code of what I've done below:
library(tseries)
globtemp <- stats::ts(
c(-0.32, -0.32, -0.4, -0.39, -0.65, -0.43, -0.4, -0.52, -0.3, -0.12,
-0.4, -0.42, -0.39, -0.45, -0.35, -0.36, -0.19, -0.14, -0.37, -0.22,
0, -0.08, -0.24, -0.36, -0.49, -0.27, -0.19, -0.43, -0.29, -0.3,
-0.29, -0.29,-0.28, -0.23, -0.04, -0.02, -0.24, -0.42, -0.35, -0.16,
-0.17, -0.09,-0.13, -0.16, -0.14, -0.14, 0.1, -0.03, 0.03, -0.18,
-0.06, 0.04, 0.02, -0.13, 0.03, -0.06, 0.02, 0.13, 0.13, -0.03,
0.15, 0.12, 0.1, 0.04, 0.11, -0.04, 0.01, 0.13, -0.01, -0.06,
-0.14, -0.02, 0.04, 0.14, -0.07, -0.06, -0.17, 0.1, 0.1, 0.05,
-0.01, 0.08, 0.02, 0.02, -0.26, -0.16, -0.09, -0.02, -0.12, 0.03,
0.04, -0.11,-0.07, 0.19, -0.07, -0.05, -0.22, 0.16, 0.09, 0.14,
0.28, 0.39, 0.07, 0.29, 0.11, 0.11, 0.16, 0.32, 0.35, 0.25,
0.47, 0.41, 0.13),
start=1880, end = 1992)
plot(globtemp)
adf.test(globtemp, k=0) #DF Test
#Dickey-Fuller = -3.4235, Lag order = 4, p-value = 0.05414
dx <- diff(globtemp)
x_lag <- globtemp[-length(globtemp)]
df_model <- lm(dx ~ x_lag)
summary(df_model)
residuals_df <- resid(df_model)
acf(residuals_df, 50, main = "") #No autocorrelation
Box.test(residuals_df, lag = 15, type = "Ljung-Box")
adf.test(globtemp) #ADF with default "k"
#Dickey-Fuller = -3.4235, Lag order = 4, p-value = 0.05414