# R Stationarity Test

From kpss.test help

package:tseries

**Level Stationary Example**

`x <- rnorm(1000) `

**# is level stationary**

kpss.test(x)

KPSS Test for Level Stationarity

data: x

KPSS Level = 0.0319, Truncation lag parameter = 7, p-value = **0.1 ** <- fail to reject null hypothesis that** x is stationary**

Warning message:

In kpss.test(x) : p-value greater than printed p-value

**Not Stationary Example**

`y <- cumsum(x) `

**# has unit root**

kpss.test(y)

KPSS Test for Level Stationarity

data: y

KPSS Level = 9.4899, Truncation lag parameter = 7, p-value = **0.01 **<- Safe to **reject null hypothesis that x is stationary**

Warning message:

In kpss.test(y) : p-value smaller than printed p-value

**Trend Stationary Example**

`x <- 0.3*(1:1000)+rnorm(1000) `

**# is trend stationary**

kpss.test(x, null = "Trend")

KPSS Test for Trend Stationarity

data: x

KPSS Trend = 0.1068, Truncation lag parameter = 7, p-value = **0.1 **<- Fail to reject null hypothesis that **x is trend stationary**

Warning message:

In kpss.test(x, null = "Trend") : p-value greater than printed p-value