Title: Compute Maximal Overlap Discrete Wavelet Transform (MODWT) and À Trous Discrete Wavelet Transform
Version: 1.0.1
Description: A lightweight package to compute Maximal Overlap Discrete Wavelet Transform (MODWT) and À Trous Discrete Wavelet Transform by leveraging the power of 'Rcpp' to make these operations fast. This package was designed for use in forecasting, and allows users avoid the inclusion of future data when performing wavelet decomposition of time series. See Quilty and Adamowski (2018) <doi:10.1016/j.jhydrol.2018.05.003>.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.2.1
LinkingTo: Rcpp
Imports: Rcpp
URL: https://github.com/johnswyou/fastWavelets
BugReports: https://github.com/johnswyou/fastWavelets/issues
NeedsCompilation: yes
Packaged: 2022-11-18 14:12:04 UTC; John
Author: John Quilty ORCID iD [aut], John You ORCID iD [aut, cre]
Maintainer: John You <johnswyou@gmail.com>
Repository: CRAN
Date/Publication: 2022-11-18 14:40:12 UTC

A Trous Discrete Wavelet Transform

Description

This function calculates the wavelet and scaling coefficients of the a trous (AT) version of the Discrete Wavelet Transform (DWT).

Usage

atrous_dwt(X, wavelet, decomp_level)

Arguments

X

An (N x 1) matrix or a vector

wavelet

Scaling filter name (see Details below) (string)

decomp_level

Decomposition level (integer, 1 < decomp_level < N/2)

Details

The argument wavelet can take one of the following values:

c("haar", "d1", "sym1", "bior1.1", "rbio1.1", "d2", "sym2", "d3", "sym3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "sym4", "sym5", "sym6", "sym7", "sym8", "sym9", "sym10", "coif1", "coif2", "coif3", "coif4", "coif5", "bior1.3", "bior1.5", "bior2.2", "bior2.4", "bior2.6", "bior2.8", "bior3.1", "bior3.3", "bior3.5", "bior3.7", "bior3.9", "bior4.4", "bior5.5", "bior6.8", "rbio1.3", "rbio1.5", "rbio2.2", "rbio2.4", "rbio2.6", "rbio2.8", "rbio3.1", "rbio3.3", "rbio3.5", "rbio3.7", "rbio3.9", "rbio4.4", "rbio5.5", "rbio6.8", "la8", "la10", "la12", "la14", "la16", "la18", "la20", "bl14", "bl18", "bl20", "fk4", "fk6", "fk8", "fk14", "fk18", "fk22", "b3spline", "mb4.2", "mb8.2", "mb8.3", "mb8.4", "mb10.3", "mb12.3", "mb14.3", "mb16.3", "mb18.3", "mb24.3", "mb32.3", "beyl", "vaid", "han2.3", "han3.3", "han4.5", "han5.5")

Value

Wavelet and scaling coefficients (N x J+1) (wavelet coefficients in first J columns of returned matrix)

References

Benaouda, D., F. Murtagh, J. L. Starck, and O. Renaud (2006), Wavelet-based nonlinear multiscale decomposition model for electricity load forecasting, Neurocomputing, doi:10.1016/j.neucom.2006.04.005.

Maheswaran, R., and R. Khosa (2012), Comparative study of different wavelets for hydrologic forecasting, Comput. Geosci., doi:10.1016/j.cageo.2011.12.015.

Examples

N <- 1000 #  number of time series points
J <- 4 # decomposition level
wavelet <- 'coif1' # wavelet filter
X <- matrix(rnorm(N),N,1)
W <- atrous_dwt(X,wavelet,J)
Xr <- as.matrix(rowSums(W)) # reconstruct time series
mse_r <- mean( (X - Xr)^2) # confirm additive reconstruction
plot.ts(W) # plot wavelet and scaling coefficients

Maximal Overlap Discrete Wavelet Transform (MODWT)

Description

This function calculates the wavelet and scaling coefficients of the MODWT.

Usage

mo_dwt(X, wavelet, decomp_level)

Arguments

X

An (N x 1) matrix or a vector

wavelet

Scaling filter name (see Details below) (string)

decomp_level

Decomposition level (integer, 1 < decomp_level < N/2)

Details

The argument wavelet can take one of the following values:

c("haar", "d1", "sym1", "d2", "sym2", "d3", "sym3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "sym4", "sym5", "sym6", "sym7", "sym8", "sym9", "sym10", "coif1", "coif2", "coif3", "coif4", "coif5", "la8", "la10", "la12", "la14", "la16", "la18", "la20", "bl14", "bl18", "bl20", "fk4", "fk6", "fk8", "fk14", "fk18", "fk22", "mb4.2", "mb8.2", "mb8.3", "mb8.4", "mb10.3", "mb12.3", "mb14.3", "mb16.3", "mb18.3", "mb24.3", "mb32.3", "beyl", "vaid", "han2.3", "han3.3", "han4.5", "han5.5" )

Value

Wavelet and scaling coefficients (N x J+1) (wavelet coefficients in first J columns of returned matrix)

References

M. Basta (2014), Additive Decomposition and Boundary Conditions in Wavelet-Based Forecasting Approaches, Acta Oeconomica Pragensia, 2, pp. 48-70.

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

Examples

N <- 1000 #  number of time series points
J <- 4 # decomposition level
wavelet <- 'coif1' # wavelet filter
X <- matrix(rnorm(N),N,1)
W <- mo_dwt(X,wavelet,J)

Number of Boundary Coefficients

Description

This function calculates the number of boundary coefficients for a particular wavelet/scaling filter and decomposition level.

Usage

n_boundary_coefs(wavelet, decomp_level)

Arguments

wavelet

Scaling filter name (see Details below) [string]

decomp_level

Decomposition level [integer]

Details

The argument wavelet can take one of the following values:

c("haar", "d1", "sym1", "bior1.1", "rbio1.1", "d2", "sym2", "d3", "sym3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "sym4", "sym5", "sym6", "sym7", "sym8", "sym9", "sym10", "coif1", "coif2", "coif3", "coif4", "coif5", "bior1.3", "bior1.5", "bior2.2", "bior2.4", "bior2.6", "bior2.8", "bior3.1", "bior3.3", "bior3.5", "bior3.7", "bior3.9", "bior4.4", "bior5.5", "bior6.8", "rbio1.3", "rbio1.5", "rbio2.2", "rbio2.4", "rbio2.6", "rbio2.8", "rbio3.1", "rbio3.3", "rbio3.5", "rbio3.7", "rbio3.9", "rbio4.4", "rbio5.5", "rbio6.8", "la8", "la10", "la12", "la14", "la16", "la18", "la20", "bl14", "bl18", "bl20", "fk4", "fk6", "fk8", "fk14", "fk18", "fk22", "b3spline")

Value

Number of boundary coefficients [integer]

References

M. Basta (2014),Additive Decomposition and Boundary Conditions in Wavelet-Based Forecasting Approaches, Acta Oeconomica Pragensia, 2, pp. 48-70.

Quilty, J., & Adamowski, J. (2018). Addressing the incorrect usage of wavelet-based hydrological and water resources forecasting models for real-world applications with best practices and a new forecasting framework. Journal of Hydrology, 563, 336–353. https://doi.org/10.1016/j.jhydrol.2018.05.003

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

Examples

J <- 4 # decomposition level
wavelet <- 'b3spline' # wavelet filter
nbc <- n_boundary_coefs(wavelet, J) # number of boundary-effected coefficients at decomp_level J

Compute Scaling Coefficients

Description

Compute the scaling coefficients.

Usage

scaling_coefs(X, wavelet, j)

Arguments

X

An (N x 1) matrix or a vector

wavelet

A character string indicating the scaling filter

j

The decomposition level [integer]

Value

An (N x 1) matrix scaling coefficients

References

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


Scaling Filter

Description

Compute the scaling filter.

Usage

scaling_filter(wavelet)

Arguments

wavelet

A character string indicating the scaling filter desired

Details

The argument wavelet can take one of the following values:

c("haar", "d1", "sym1", "bior1.1", "rbio1.1", "d2", "sym2", "d3", "sym3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "sym4", "sym5", "sym6", "sym7", "sym8", "sym9", "sym10", "coif1", "coif2", "coif3", "coif4", "coif5", "bior1.3", "bior1.5", "bior2.2", "bior2.4", "bior2.6", "bior2.8", "bior3.1", "bior3.3", "bior3.5", "bior3.7", "bior3.9", "bior4.4", "bior5.5", "bior6.8", "rbio1.3", "rbio1.5", "rbio2.2", "rbio2.4", "rbio2.6", "rbio2.8", "rbio3.1", "rbio3.3", "rbio3.5", "rbio3.7", "rbio3.9", "rbio4.4", "rbio5.5", "rbio6.8", "la8", "la10", "la12", "la14", "la16", "la18", "la20", "bl14", "bl18", "bl20", "fk4", "fk6", "fk8", "fk14", "fk18", "fk22", "b3spline", "mb4.2", "mb8.2", "mb8.3", "mb8.4", "mb10.3", "mb12.3", "mb14.3", "mb16.3", "mb18.3", "mb24.3", "mb32.3", "beyl", "vaid", "han2.3", "han3.3", "han4.5", "han5.5")

Value

Scaling filter vector (a numeric vector)

References

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

Wasilewski, F. (2008). Wavelet browser by pywavelets. Wavelet Properties Browser. Retrieved November 17, 2022, from http://wavelets.pybytes.com/

Gregory R. Lee, Ralf Gommers, Filip Wasilewski, Kai Wohlfahrt, Aaron O’Leary (2019). PyWavelets: A Python package for wavelet analysis. Journal of Open Source Software, 4(36), 1237, https://doi.org/10.21105/joss.01237.

Olhede, S., & Walden, A. T. (2004). The Hilbert spectrum via wavelet projections. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 460(2044), 955–975. https://doi.org/10.1098/rspa.2003.1199

Maheswaran, R., & Khosa, R. (2012). Comparative study of different wavelets for hydrologic forecasting. Computers & Geosciences, 46, 284–295. https://doi.org/10.1016/j.cageo.2011.12.015


Check Matrix X is (N x 1)

Description

shape_check checks whether X is a matrix representing a column vector (i.e., a matrix with 1 column). If not, shape_check attempts to coerce the user provided X to a matrix with 1 column. If this cannot be done, an error is raised.

Usage

shape_check(X)

Arguments

X

Object to check and (if possible) coerce to a single column matrix

Details

This is a utility function written to check the input X for the functions atrous_dwt and mo_dwt.

Value

An (N x 1) matrix


Compute Wavelet Coefficients

Description

Compute the wavelet coefficients.

Usage

wavelet_coefs(X, wavelet, j)

Arguments

X

An (N x 1) matrix or a vector

wavelet

A character string indicating the scaling filter

j

The decomposition level [integer]

Value

(N x 1) matrix of wavelet coefficients

References

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


Compute the Wavelet Filter

Description

Compute the wavelet filter.

Usage

wavelet_filter(wavelet)

Arguments

wavelet

A character string indicating the wavelet filter desired

Value

Wavelet filter vector (a numeric vector)

References

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