Performs Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test for the null
x is a stationary univariate time series.
a numeric vector or univariate time series.
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.
a logical value indicating to print out the results in R console.
The default is
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] = α*t + u[t] + e[t],
where u[t] satisfies u[t] = u[t-1] + a[t], and a[t] are i.i.d
(0,σ^2). The null hypothesis is that σ^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,
x[t] = u[t] + e[t].
The second type (
type2) is the one with drift but no trend:
x[t] = μ + u[t] + e[t].
The third type (
type3) is the one with both drift and trend:
x[t] = μ + α*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(
A matrix for test results with three columns (
p.value) and three rows (
Each row is the test results (including lag parameter, test statistic and p.value) for
each type of linear regression models.
Missing values are removed.
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.
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.