Learn R Programming

aTSA (version 3.1.2.1)

kpss.test: Kwiatkowski-Phillips-Schmidt-Shin Test

Description

Performs Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test for the null hypothesis that x is a stationary univariate time series.

Usage

kpss.test(x, lag.short = TRUE, output = TRUE)

Value

A matrix for test results with three columns (lag, kpss, p.value) and three rows (type1, type2, type3). Each row is the test results (including lag parameter, test statistic and p.value) for each type of linear regression models.

Arguments

x

a numeric vector or univariate time series.

lag.short

a logical value indicating whether the parameter of lag to calculate the test statistic is a short or long term. The default is a short term. See details.

output

a logical value indicating to print out the results in R console. The default is TRUE.

Author

Debin Qiu

Details

The Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test tends to decompose the time series into the sum of a deterministic trend, a random walk, and a stationary error: $$x[t] = \alpha*t + u[t] + e[t],$$ where \(u[t]\) satisfies \(u[t] = u[t-1] + a[t]\), and \(a[t]\) are i.i.d \((0,\sigma^2)\). The null hypothesis is that \(\sigma^2 = 0\), which implies x is a stationary time series. In order to calculate the test statistic, we consider three types of linear regression models. The first type (type1) is the one with no drift and deterministic trend, defined as $$x[t] = u[t] + e[t].$$ The second type (type2) is the one with drift but no trend: $$x[t] = \mu + u[t] + e[t].$$ The third type (type3) is the one with both drift and trend: $$x[t] = \mu + \alpha*t + u[t] + e[t].$$ The details of calculation of test statistic (kpss) can be seen in the references below. The default parameter of lag to calculate the test statistic is \(max(1,floor(3*sqrt(n)/13)\) for short term effect, otherwise, \(max(1,floor(10*sqrt(n)/13)\) for long term effect. The p.value is calculated by the interpolation of test statistic from tables of critical values (Table 5, Hobijn B., Franses PH. and Ooms M (2004)) for a given sample size \(n\) = length(x).

References

Hobijn B, Franses PH and Ooms M (2004). Generalization of the KPSS-test for stationarity. Statistica Neerlandica, vol. 58, p. 482-502.

Kwiatkowski, D.; Phillips, P. C. B.; Schmidt, P.; Shin, Y. (1992). Testing the null hypothesis of stationarity against the alternative of a unit root. Journal of Econometrics, 54 (1-3): 159-178.

See Also

adf.test, pp.test, stationary.test

Examples

Run this code
# KPSS test for AR(1) process
x <- arima.sim(list(order = c(1,0,0),ar = 0.2),n = 100)
kpss.test(x)

# KPSS test for co2 data
kpss.test(co2)

Run the code above in your browser using DataLab