hwtos {locits} | R Documentation |
Haar wavelet test for (second-order) stationarity for arbitrary length time series.
Description
NOTE: CURRENTLY THIS FUNCTION IS NOT INCLUDED IN THE PACKAGE.
USE hwtos2. This function computes the raw wavelet periodogram of the
arbitrary time series vector x
. The periodogram is then
subject to a hypothesis test to see if its expectation over time,
for different scales, is constant. The constancy test is carried out
using tests on its Haar wavelet coefficients. The overall test is
for second-order stationarity (e.g. constant variance, constant
acf function, mean is assumed zero).
Usage
hwtos(x, alpha = 0.05, lowlev = 1, WTscale = NULL, maxSD = NULL,
verbose = FALSE, silent = FALSE, UseCForVarip2 = TRUE, OPLENGTH = 1e+05,
mc.method = p.adjust.methods)
Arguments
x |
The time series you wish to test for second-order stationarity.
Minimum length series that this function will operate for is 20.
However, for short series the power of the test might not be good
and could be investigated via simulation that reflect your particular
circumstances.
This should be a stochastic series. The function
will report an error if |
alpha |
The (nominal) size of the hypothesis test. |
lowlev |
Controls the lowest scale of the wavelet periodogram that gets analyzed. Generally, leave this parameter alone. |
WTscale |
Controls the finest scale of the Haar wavelet transform of a particular wavelet periodogram scale. Generally, we have to stay away from the finest Haar wavelet transform scales of the periodogram as the test relies on a central limit theorem effect which only "kicks in" when the Haar wavelet scale is medium-to-coarse. Generally, leave this argument alone. |
maxSD |
Parameter which controls which scales go towards overall variance calculation. Generally, leave alone. |
verbose |
If |
silent |
If |
UseCForVarip2 |
If |
OPLENGTH |
Some of the internal functions require workspace to perform their calculations. In exceptional circumstances more static workspace might be required and so this argument might need to be higher than the default. However, the code will tell you how high this number will need to be. The code can, with default arguments, handle series that are up to 30000 in length. However, at 35000 the OPLENGTH parameter will need to be increased. |
mc.method |
Method to control overall size for test taking into
account multiple comparisons. The default argument is
|
Details
This function computes all possible Haar wavelet coefficients
of the time series x
. Then, squares those to obtain the
raw wavelet periodogram. Then the test of stationarity works
by taking each level of the raw wavelet periodogram and subjecting
it to another (decimated) Haar wavelet transform and then assessing
whether any of those coefficients is significantly different to
zero. It does this by using a Gaussian approximation first
introduced by Neumann and von Sachs (2000). This is a multiple
testing problem: many individual wavelet coefficients need to
be assessed simultaneously and the user can choose the type of
assessment using the mc.method
argument.
Value
An object of class tosANYN
. This is a list containing the
following components.
nreject |
The number of wavelet coefficients that reject the null hypothesis of being zero. |
mc.method |
The multiple comparison method used. |
AllTS |
All the t-statistics. This is a list containing J levels,
where J is the number of periodogram levels. Each slot in
the |
AllPVal |
As |
alpha |
The size of the test |
x |
The time series that was analyzed |
xSD |
The estimated mean spectrum value for each level of the spectrum, mean over time that is. |
allTS |
A vector containing all of the test statistics. So,
the information in |
allpvals |
As |
allbigscale |
The wavelet periodogram scale associated with each
t-statistic in |
alllitscale |
As for |
allindex |
As for |
alllv |
The maximum number of wavelet coefficients in a particular Haar wavelet scale of a particular scale of the wavelet periodogram. Note, this information is useful because the wavelet transforms are computed on arbitrary length objects and so keeping track of the number of coefficients per scale is useful later, e.g. for plotting purposes. This information is not required in the dyadic case because the coefficient vector lengths are completely predictable. |
allpvals.unadjust |
A vector of p-values that has not been adjusted by a multiple hypothesis test technique. |
Author(s)
G. P. Nason
References
Nason, G.P. (2013) A test for second-order stationarity and approximate confidence intervals for localized autocovariances for locally stationary time series. J. R. Statist. Soc. B, 75, 879-904. doi:10.1111/rssb.12015
Priestley, M.B. and Subba Rao (1969) A test for non-stationarity of time series. J. R. Statist. Soc. B, 31, 140-149.
von Sachs, R. and Neumann, M.H. (2000) A wavelet-based test for stationarity. J. Time Ser. Anal., 21, 597-613.
See Also
link{hwt}
,
hwtos2
,
plot.tosANYN
,
print.tosANYN
,
summary.tosANYN
Examples
#
# Generate test data set of non-dyadic length
#
v3 <- rnorm(300)
#
# Run the test of stationarity
#
## Not run: v3.TOS <- hwtos(v3)
#
#Scales get printed
#8 7 6 5 4 3 2
#
## Not run: print(v3.TOS)
#Class 'tosANYN' : Stationarity Object for Arbitrary Length Data :
# ~~~~~~~ : List with 14 components with names
# nreject mc.method AllTS AllPVal alpha x xSD allTS
# allpvals allbigscale alllitscale allindex alllv
# allpvals.unadjust
#
#
#summary(.):
#----------
#There are 54 hypothesis tests altogether
#There were 0 reject(s)
#P-val adjustment method was: holm
#
# Note, nothing got rejected. So accept the H_0 null hypothesis of stationarity.
# This is precisely what you'd expect operating on iid Gaussians.
#
# Let's construct obvious example of non-stationarity.
#
v4 <- c(rnorm(150), rnorm(150,sd=3))
#
# I.e. v4 has sharp variance change halfway along
# Now compute test of stationarity
#
## Not run: v4.TOS <- hwtos(v4)
#
# Print out results
#
## Not run: print(v4.TOS)
#
#Class 'tosANYN' : Stationarity Object for Arbitrary Length Data :
# ~~~~~~~ : List with 14 components with names
# nreject mc.method AllTS AllPVal alpha x xSD allTS
# allpvals allbigscale alllitscale allindex alllv
# allpvals.unadjust
#
#
#summary(.):
#----------
#There are 54 hypothesis tests altogether
#There were 5 reject(s)
#P-val adjustment method was: holm
#Listing rejects...
#P: 7 HWTlev: 2 Max Poss Ix: 2 Indices: 2
#P: 7 HWTlev: 1 Max Poss Ix: 1 Indices: 1
#P: 6 HWTlev: 1 Max Poss Ix: 1 Indices: 1
#P: 5 HWTlev: 1 Max Poss Ix: 1 Indices: 1
#P: 4 HWTlev: 1 Max Poss Ix: 1 Indices: 1