hwt {locits} | R Documentation |
Compute a Haar wavelet transform for data of arbitrary n length
Description
Function computes Haar wavelet and scaling function coefficients for data set of any length. Algorithm computes every possible coefficient that it can for both decimated and nondecimated versions of the transform.
Usage
hwt(x, type = c("wavelet", "station"), reindex = FALSE)
Arguments
x |
A vector of length n, where n is a positive integer. This is the data that you wish to compute the Haar wavelet transform for. |
type |
The type of transform, either the decimated or nondecimated algorithm. |
reindex |
If TRUE then the routine attempts to match scales
with the usual dyadic transform, |
Details
Essentially, this algorithm attempts to compute every
possible Haar wavelet coefficient. For example, if the length
of the input series was 6 then this means that three coefficients
at the finest scale can be computed using the first, second and
third pair of input data points using the weights
c(1, -1)/sqrt(2)
. However, from the three coefficients
that result from this, there is only one pair, so only one
"next coarser" coefficient can be computed.
The reindex
option is subtle. Essentially, it tries to
ensure that the returned coefficients end up at the same
scales as if a data set of the next highest dyadic length was
analyzed by the wd function. E.g. if the length of the
series was 10 then with reindex=FALSE
(default)
only three levels are returned for each of the wavelet and
scaling coefficients. If reindex=TRUE
then the number
of levels returned would be as if wd
analysed a data set
of length 16 (the smallest dyadic number larger than 10).
The wd levels would be zero to three and this is what
would be returned in this function if reindex=TRUE
.
However, note, in this case, the coarsest level coefficient
happens to be NULL (or not computable). One can view the algorithm
as computing a partial transform of 10 of the 16 elements and
substituting NA for anything it can't compute.
Value
An object of class hwtANYN which is a list with the following components.
c |
The scaling function coefficients. This is a list of length
|
d |
A for |
nlevels |
The number of scale levels in the Haar wavelet decomposition.
if |
type |
Whether a decimated wavelet transform has been computed
( |
reindex |
Either |
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
hwtos
,
plot.hwtANYN
, print.hwtANYN
,
summary.hwtANYN
Examples
#
# Generate test data set of length 5 (note, NOT a power of two)
#
v2 <- rnorm(5)
#
# Compute its Haar transform
#
v2hwt <- hwt(v2)
#
# How many levels does it have?
#
nlevelsWT(v2hwt)
#
# What are the coarsest scale wavelet coefficients
#
v2hwt$d[[1]]
#
# What are the finest scale scaling function coefficients
#
v2hwt$c[[nlevels(v2hwt$c)-1]]