Testing for stationarity in a time series
The Priestley-Subba Rao (PSR) test for nonstationarity is based upon examining how homogeneous a set of spectral density function (SDF) estimates are across time, across frequency, or both. The original test was formulated in the terms of localized lag window SDF estimators, but such estimators can suffer from bias due to leakage. To circumvent this potential problem, the SDF estimators are averages of multitaper SDF estimates using orthogonal sinusoidal tapers.
1 2 3
a vector containing a uniformly-sampled real-valued time series.
a logical value. If
the number of non-overlapping blocks with which the
time series will be uniformly divided. If the number of samples in the time series
is not evenly divisible by
an integer specifying the number of sinusoidal tapers to use in developing the eigenspectra for each block of the time series. Default: 5.
a logical value. If
the significance is the number of times you expect the underlying hypothesis of stationarity to fail even though stationarity remains true. Essentially, you are allowing for error in the result. A significance of 0.05 means that you are allowing 5 percent error, i.e., you are 95 percent confident in the result. Default: 0.05.
The algorithms is outlined as follows:
- 1. Re-centering
The time series
xis recentered by subtracting the sample mean.
- 2. Blocking
The recentered series is then segmented into
n.blocknon-overlapping blocks in time.
- 3. Mutitaper SDF estimation
For each block,
n.tapereigenspectra are formed by calculating the periodogram of the block windowed by each of the
n.tapertapers. These eiegenspectra are then averaged to form a multitaper SDF estimator for the current block.
- 4. ANOVA table
A subset of each multitaper SDF estimate is formed by extracting only those values corresponding to frequencies which are approximately uncorrelated (the details of this exercise can be found in the references). Each subset (one per block) is stacked in rows such that an
n.blockx M matrix (S) is formed, where M is the number of (subset) Fourier frequencies. The (two-factor) ANOVA table (Y) is then formed via Y=log(S) - psi(n.taper) + log(n.taper), where psi() is the digamma function and log is the natural logarithm function.
- 5. PSR statistics
Using the ANOVA table and (row, column, and grand) means of the ANOVA table, the Priesltey-Subba Rao statistics are generated: one for investigating time effects, one for investigating frequency effects, and one which combines the two to test time-frequency effects. See references for details.
- 6. Stationarity tests
The PSR statisitcs are then compared to corresponding chi-square (
(1 - significance)x 100) percentiles (normalized by psi'(n.taper) where psi'() is the trigamma function). Specifically, if the PSR statistic is found to be greater than the corresponding chi-square percentile, it indicates that there is a
1 - significanceprobability that the data is nonstationary.
an object of class
convert output to a list.
prints the object. Available options are:
text justification ala
header separator ala
number of digits ala
prettyPrintList. Default: 5.
Additional print arguments sent directly to the
prints a summary of the stationarity test results.
Priestley, M. B. and Subba Rao, T. (1969) “A Test for Stationarity of Time Series", Journal of the Royal Statistical Society, Series B, 31, pp. 140–9.
1 2 3 4 5 6 7 8 9 10 11
## assess the stationarity of the ecgrr series z <- stationarity(ecgrr, n.block=8) ## print the result, noting that all tests fail. ## The strongest failure attributed to the ## time-based fluctations of the eigenspectra print(z) ## print a summary of the results, including the ## ANOVA table of the eigenspectra summary(z)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.