Learn R Programming

wmtsa (version 2.0-3)

wavDWTMatrix: Discrete wavelet transform matrix.

Description

Returns the discrete wavelet transform matrix for the specified wavelet and decomposition level.

Usage

wavDWTMatrix(wavelet="d4", J=4, J0=J)

Arguments

wavelet

character string defining Daubechies wavelet filter.

J

integer scalar defining maximum decomposition level.

J0

integer scaling defining the partial decomposition level. Note that necessarily J0 <= J, otherwise an error will be thrown.

Value

discrete wavelet transform matrix

Details

The discrete wavelet transform of a real-valued uniformly-sampled time series \(X_t\) for t=0,...,N-1 can be written in matrix form as \(\mathbf{W} = \mathcal{W}\mathbf{X}\), where \(\mathbf{W}\) are the N x 1 transform coefficients and \(\mathcal{W}\) is an orthonormal matrix of size N x N known as the discrete wavelet transform matrix. Generally, the discrete wavelet transform is calculated via a computationally efficient pyramid algorithm and not via the matrix form above. However, it serves as a good illustration and is primarily used for pedagogical interest. We highly recommend using the equivalent and highly efficient alternative functions in this package for computing the discrete wavelet transform such as wavDWT.

Note that the length of the time series is taken to be N=2^J. You can obtain the discrete wavelet transform matrix for a partial transform by setting J0 < J. By default, J0=J.

References

D. B. Percival and A. T. Walden, Wavelet Methods for Time Series Analysis, Cambridge University Press, 2000.

See Also

wavDaubechies, wavDWT.

Examples

Run this code
# NOT RUN {
# Plot some rows of the wavelet transform matrix for the Haar filter
B <- wavDWTMatrix(wavelet = 'haar', J = 4)
wavStemPlot(B[1,])
wavStemPlot(B[15,])
wavStemPlot(B[16,])

# Compare the wavelet transform coefficients via the efficient
# wavDWT and non-efficient matrix multiplaction methods
N <- 256
X <- rnorm(N)
J0 <- 3
J <- as.integer(log2(N))
wavelet <- 's8'
W <- wavDWT(x = X, wavelet = wavelet, n.levels = J0)
B <- wavDWTMatrix(wavelet = wavelet, J = J, J0 = J0)
all.equal.numeric(as.vector(unlist(W$data)), as.vector(B %*% X))
# }

Run the code above in your browser using DataLab