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 = "")