# Interpreting results of KPSS test in R

I've been trying to create an ARIMA model however, I'm not sure how to determine if the data is stationary or not. I preformed a KPSS test in R using kpss.test from package tseries and these are the results:

KPSS Level = 1.966, Truncation lag parameter = 5, p-value = 0.01

Warning message:
In kpss.test(coke[,5], null = "Level") : p-value smaller than printed p-value


You specified a KPSS test of the null hypothesis that the time series coke[, 5] is level stationary (i.e., stationary around a constant mean). This is tested against the alternative that the series is not stationary (i.e., of integration order I(1)), leading to a significant result (at conventional significance levels). The precise p-value is not shown, however, just 0.01 which is the smallest p-value tabulated in the package.

As already explained by @AchimZeileis, the results show that the null hypothesis of stationarity is rejected at the 5% significance level.

If the data show a trend pattern, you may be interested in testing the alternative that the series is stationary around a linear trend. For that, you can use the argument null = "Trend".

The rejection of stationarity may be affected by level shifts or spikes (additive outliers). It is advisable to check for the presence of this kind of anomalies. In R, you can use the package tsoutliers.

Sometimes it happens that after accounting for a level shift in the series, the null of stationarity is no longer rejected. A typical example is the Nile time series. The null hypothesis of the KPSS test is rejected:

require("tseries")
kpss.test(Nile)
# KPSS Test for Level Stationarity
# KPSS Level = 1.3152, Truncation lag parameter = 2, p-value = 0.01
# Warning message:
# In kpss.test(Nile) : p-value smaller than printed p-value


The function tsoutliers::tso detects a level shift at observation 29 (and an additive outlier at observation 43). The null of the KPSS test is not rejected for the series adjusted for this shift (also notice that the model chosen by forecast::auto.arima has no ARIMA structure).

res <- tso(y = Nile, tsmethod = "auto.arima")
res
# Series: Nile
# ARIMA(0,0,0) with non-zero mean
# Coefficients:
#       intercept       LS29       AO43
#       1097.7500  -242.2289  -399.5211
# s.e.    22.6783    26.7793   120.8446
# Outliers:
# type ind time coefhat  tstat
# 1   LS  29 1899  -242.2 -9.045
# 2   AO  43 1913  -399.5 -3.306
kpss.test(res$yadj) # KPSS Test for Level Stationarity # data: res$yadj
# KPSS Level = 0.0536, Truncation lag parameter = 2, p-value = 0.1
# Warning message:
# In kpss.test(res\$yadj) : p-value greater than printed p-value