Learn R Programming

fractal (version 2.0-4)

stationarity: Testing for stationarity in a time series

Description

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.

Usage

stationarity(x, n.taper=5,
    n.block=max(c(2, floor(logb(length(x), base=2)))), significance=0.05,
    center=TRUE, recenter=FALSE)

Arguments

x

a vector containing a uniformly-sampled real-valued time series.

center

a logical value. If TRUE, The mean value of the data is subtracted from the original series prior to analyis. Default: TRUE.

n.block

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 n.block, then those samples at the of the time series that do not fit into the last block are ignored (rejected for analysis). Default: max(c(2, floor(logb(length(x), base=2)))).

n.taper

an integer specifying the number of sinusoidal tapers to use in developing the eigenspectra for each block of the time series. Default: 5.

recenter

a logical value. If TRUE, the mean value of the data is subtracted from the tapered series prior to forming a mutltiaper SDF estimate of the input time series. Default: TRUE.

significance

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.

Value

an object of class stationarity.

S3 METHODS

as.list

convert output to a list.

print

prints the object. Available options are:

justify

text justification ala prettPrintList. Default: "left".

sep

header separator ala prettyPrintList. Default: ":".

n.digits

number of digits ala prettyPrintList. Default: 5.

...

Additional print arguments sent directly to the prettyPrintList function).

summary

prints a summary of the stationarity test results.

Details

The algorithms is outlined as follows:

1. Re-centering

The time series x is recentered by subtracting the sample mean.

2. Blocking

The recentered series is then segmented into n.block non-overlapping blocks in time.

3. Mutitaper SDF estimation

For each block, n.taper eigenspectra are formed by calculating the periodogram of the block windowed by each of the n.taper tapers. 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.block x \(M\) matrix (S) is formed, where \(M\) is the number of (subset) Fourier frequencies. The (two-factor) ANOVA table (Y) is then formed via \(\mathbf{Y} \equiv \log(\mathbf{S}) - \psi(\mbox{n.taper}) + \log(\mbox{n.taper})\), where \(\psi(\cdot)\) 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'(\mbox{n.taper})\) where \(\psi'(\cdot)\) 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 - significance probability that the data is nonstationary.

References

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.

See Also

hurstBlock.

Examples

Run this code
# NOT RUN {
## 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)
# }

Run the code above in your browser using DataLab