Simulate a KPSS Test to Assess Unit Root in a Time Series
skpss_test.Rd
skpss_test()
provides a simulation approach to assessing
unit root in a time series by way of KPSS test, first proposed by Kwiatkowski
et al. (1992). It takes a vector and extracts the residuals from two models to
assess stationarity around a level or trend, producing a KPSS test statistic
(eta). Rather than interpolate or approximate a p-value, it simulates
some user-specified number of KPSS of either a known, stationary time series
(default) or a known, non-stationary time series matching the length of the
time series the user provides. This allows the user to make assessments of
non-stationarity or stationarity by way of simulation rather than
approximation from received critical values by way of various books/tables.
Arguments
- x
a vector
- lag_short
logical, defaults to
TRUE
. IfTRUE
, the "short-term" lag is used for the KPSS test. IfFALSE
, the "long-term" lag is used. These lags are those suggested by Schwert (1989).- n_sims
the number of simulations for calculating an interval or distribution of test statistics for assessing stationarity or non-stationarity. Defaults to 1,000.
- sim_hyp
can be either "stationary" or "nonstationary". If "stationary" (default), the function runs KPSS tests on simulated stationary (pure white noise) data. This allows the user to assess compatibility/plausibility of the test statistic against a distribution of test statistics that are known to be pure white noise (in expectation). If "nonstationary", the simulations are conducted on two different random walks. The "trend" test includes a level drawn from a Rademacher distribution with a time trend of that level, divided by 10.
Value
skpss_test()
returns a list of length 3. The first element
in the list is a matrix of eta statistics calculated by the test. The first
of those is the level statistic and the second of those is the trend
statistic. The second element is a data frame of the simulated eta statistics,
where the type of simulation (level, trend) is communicated in the cat
column.
The third element contains some attributes about the procedure for
post-processing.
Details
Recall that this procedure defaults from almost every other unit root test by making stationarity a null hypothesis. Non-stationarity is the alternative hypothesis.
As of writing, the default lags are those suggested by Schwert (1989) to apply to the Bartlett kernel generating the KPSS test statistic (eta).
aTSA has a particularly interesting approach to this test that draws on on insights seemingly proposed by Hobijn et al. (2004). Future updates to this function may propose those, but this function, as is, performs calculations of eta identical to what tseries or urca would produce. Right now, I don't have the time or energy to get into the weeds of what Hobijn et al. (2004) are doing or what aTSA is implementing, but it seems pretty cool.
This function removes missing values from the vector before calculating test statistics.
References
Hobijn, Bart, Philip Hans Franses, and Marius Ooms. 2004. "Generalizations of the KPSS-test for Stationarity". Statistica Neerlandica 58(4): 483–502.
Kwiatkowski, Denis, Peter C.B. Phillips, Peter Schmidt, and Yongcheol Shin. 1992. "Testing the Null Hypothesis of Stationarity Against the Alternative of a Unit Root: How Sure Are We that Economic Time Series Have a Unit Root?" Journal of Econometrics 54(1-3): 159–78.
Examples
x <- USDSEK$close[1:500] # note: one missing obs here; becomes series of 499
skpss_test(x, n_sims = 25) # make it quick...
#> $stats
#> [,1]
#> [1,] 5.5806142
#> [2,] 0.8224293
#>
#> $sims
#> eta sim cat
#> 1 0.08182061 1 Level
#> 2 0.06540688 1 Trend
#> 3 0.07342573 2 Level
#> 4 0.07353076 2 Trend
#> 5 0.05906380 3 Level
#> 6 0.05981271 3 Trend
#> 7 0.12157458 4 Level
#> 8 0.06391190 4 Trend
#> 9 0.81424508 5 Level
#> 10 0.10771649 5 Trend
#> 11 0.06366934 6 Level
#> 12 0.05770480 6 Trend
#> 13 0.14076629 7 Level
#> 14 0.01993793 7 Trend
#> 15 0.05057830 8 Level
#> 16 0.02451534 8 Trend
#> 17 0.08775550 9 Level
#> 18 0.07885319 9 Trend
#> 19 0.06335264 10 Level
#> 20 0.06371417 10 Trend
#> 21 0.60814188 11 Level
#> 22 0.05120372 11 Trend
#> 23 0.05472041 12 Level
#> 24 0.04539333 12 Trend
#> 25 0.32218798 13 Level
#> 26 0.06085852 13 Trend
#> 27 0.05188075 14 Level
#> 28 0.04917586 14 Trend
#> 29 0.06435751 15 Level
#> 30 0.02755912 15 Trend
#> 31 0.27164413 16 Level
#> 32 0.04349408 16 Trend
#> 33 0.06873546 17 Level
#> 34 0.06858402 17 Trend
#> 35 0.06543743 18 Level
#> 36 0.06361372 18 Trend
#> 37 0.08011049 19 Level
#> 38 0.02936793 19 Trend
#> 39 0.05668239 20 Level
#> 40 0.05810353 20 Trend
#> 41 0.09950689 21 Level
#> 42 0.10026627 21 Trend
#> 43 0.11575784 22 Level
#> 44 0.11985723 22 Trend
#> 45 0.06079271 23 Level
#> 46 0.05061170 23 Trend
#> 47 0.22614492 24 Level
#> 48 0.06490745 24 Trend
#> 49 0.25467422 25 Level
#> 50 0.09601638 25 Trend
#>
#> $attributes
#> lags sim_hyp n_sims n test
#> 1 5 stationary 25 499 kpss
#>
#> attr(,"class")
#> [1] "skpss_test"