Solved – Confusing results on kpss.test() for stationarity

kpss-testrstationaritytrend

I've got a dataset which clearly shows a trend. However, I want to assess whether this trend is deterministic or stochastic. If I understood it right, I would need to use differences if the trend is stochastic and I could just detrend it if the trend is deterministic.

Hence, I used the kpss.test() from the tseries package in R with the null hypothesis that my data is trend-stationary which gave me a p-value of 0.01, i.e. I have evidence that it is not trend-stationary and the trend is stochastic, right?

On the other hand, I made a regression to identify the (possibly present) deterministic trend and made an additional kpss.test() on the residuals with the null of level-stationarity. This gave me a p-value of 0.1, i.e. I can't reject the null of my data being stationary after detrending, right?

Am I missing something or is there a possible further test I should use?

Here is my data:

y <- ts(c(12.9860268, 12.5362944, 10.9379455, 10.7029227, 9.6421311, 
  8.168712, 7.0846535, 6.7134053, 6.5685634, 5.6701865, 4.2352191, 
  4.3919294, 3.1960928, 2.8841746, 2.1974112, 0.5650275, -0.5647561, 
  -1.7419743, -2.9294583, -4.456346, -4.9608364, -5.3176373, -7.8000258, 
  -8.4957238, -10.1346795, -10.9322896, -11.491641, -12.1036813, 
  -13.022572, -14.5290742), start = 1982)

The regression and its fitted values and residuals are given by

m <- lm(y ~ time(y))
f <- ts(fitted(m), start = 1982)
r <- ts(residuals(m), start = 1982)

The KPSS test results are

library("tseries")
kpss.test(y, null = "Trend")
##         KPSS Test for Trend Stationarity
## 
## data:  y
## KPSS Trend = 0.30727, Truncation lag parameter = 1, p-value = 0.01    
kpss.test(r, null = "Level")
##         KPSS Test for Level Stationarity
## 
## data:  r
## KPSS Level = 0.30727, Truncation lag parameter = 1, p-value = 0.1

And a plot of the data and the residuals from the regression:

plot(y, type = "o", main = "data", xlab = "years", ylab = "")
lines(f, col = 2)
plot(r, type = "o", main = "residuals", xlab = "years", ylab = "")

enter image description here

Best Answer

Note that the test statistic is in the two versions of your test is exactly identical. The reason for this is that for the null = "Trend" case exactly the same computation is used as you did: computing the residuals from a simple linear regression and then compute the test statistic "as usual".

However, this changes the distribution of the test statistic so that the computation of critical values and p-values has to be adapted. This is also easy to see in the source code of kpss.test() which is based on the simulated critical values at 1%, 2.5%, 5%, and 10% level from the original paper. In the case of trend stationarity the critical values are: 0.216, 0.176, 0.146, 0.119 (i.e., 0.307 is significant). In contrast, in the case of level stationarity the critical values are: 0.739, 0.574, 0.463, 0.347 (where 0.307 would not be significant).

In short: In your case the first test of trend stationarity is the appropriate one while the second test of the residuals is not.