Discrete Wavelet Transform

DESCRIPTION:

Applies the Discrete Wavelet Transform (DWT) to a time series or a vector.

USAGE:

dwt(x, wavelet="s8", n.levels=6, boundary=NULL, 
    precondition=F, pdeg=0, pfrac=0, dual=F, 
    analysis.filter=NULL, synthesis.filter=NULL, 
    filter.reverse=F) 
as.dwt(x) 
idwt(x) 

REQUIRED ARGUMENTS:

x
a vector or time series object. For as.dwt, x is an object of class "ptable". For idwt, x is an object of class "dwt".

OPTIONAL ARGUMENTS:

wavelet
a character string giving the name of the wavelet, e.g. "d4", "s8". See wavelet for a list of all available wavelet names. For user-provided filter, input the values in analysis.filter and synthesis.filter below.
n.levels
a non-negative integer specifying number of multi-resolution levels. If n.levels is bigger than ml, where ml is the maximum possible level, then n.levels is set to ml and a warning message is given. The max.level function is used to compute ml.
boundary
a character string giving the boundary rules, e.g. "periodic", "infinite", "zero". See details below for a list of available boundary rules.
precondition
logical flag: for boundary="interval" only. If TRUE, then a preconditioning transform will be applied to the the data. The preconditioning transformation preserves the vanishing moments property when the DWT is applied to polynomial signals. See Cohen, Daubechies, and Vial (1993) for details.
pdeg
for "infinite"only: degree of polynomial used for boundary extension.
pfrac
for boundary="infinite"only: fraction of data used to fit a polynomial of degree pdeg.
dual
logical flag indicating if dual filter is used for analysis instead of synthesis. This argument only applies for biorthogonal wavelets. See wavelet for details.
analysis.filter
for user-defined analysis filter. See filter argument in wave.filter for details.
synthesis.filter
for user-defined synthesis filter. See filter argument in wave.filter for details. When analysis.filter is provided, then the default synthesis.filter is also analysis.filter.
filter.reverse
logical flag indicating should wavelet filters be reversed, see details below.

VALUE:

an object of class dwt, inheriting from the class "wpt", "wp", and "crystal.vector" or "crystal.list". When boundary="infinite", the DWT is a list inheriting from class crystal.list; for other boundary rules, the DWT is a vector inheriting from class crystal.vector . See crystal.list.object and crystal.vector.object for details. as.dwt coerces a ptable object to a dwt object. idwt applies the inverse DWT to the transform coefficients to reconstruct the original signal.

DETAILS:

Available boundary rules:

periodic:

the original series is assumed to be periodic. Sample size must be divisible by 2^(n.levels).

poly0:
at each level, series is extended using a polynomial extrapolation of degree 0.
poly1:
at each level, series is extended using a polynomial extrapolation of degree 1.
poly2:
at each level, series is extended using a polynomial extrapolation of degree 1.
zero:
at each level, the series is extended using zeros.
reflection:
the series is reflected (and then periodically extended). For perfect reconstruction, biorthogonal symmetric/antisymmetric wavelets are needed.
interval:
uses Cohen, Daubechies and Vial's interval wavelets. Sample size must be divisible by 2^(n.levels). For wavelet="s4", "s6", "s8", "s10", "s12", "s14", "s16" only.
infinite:
the signal is padded using a polynomial (of degree pdeg) extension; a fraction (specified by pfrac) of data are used to fit two polynomial regression models, one for each end. For each crystal, extra coefficients (of maginitude O(length(filter))) are stored as left.pad and right.pad in order to recover all the coefficients (infinite number of them!).

The default boundary rule is set based on sample size, filter length in the following way: if n.levels can be achieved by "periodic" boundary rule (i.e. sample size is divisible by 2^n.levels), then the boundary is set to be "periodic" ; otherwise, the boundary is set to be either "reflection" (for biorthogonal symmetric/anti-symmetric wavelets), or "zero". Reversed wavelet filter is also a wavelet filter. The corresponding wavelet function will be flipped around the middle of its support. All the properties of the original wavelet are preserved. All the default optional arguments can be reset using function wavelet.options . See wavelet.options for details.

REFERENCES:

Daubechies, I. (1992). Ten Lectures on Wavelets. SIAM, Philadelphia.

Cohen, A., Daubechies, I. and Vial, P. (1993). Wavelets on the Interval and Fast Wavelet Transforms, Applied and Computational Harmonic Analysis, Vol 1, 54-81.

SEE ALSO:

, , , , , , , .

EXAMPLES:

xx <- make.signal("doppler", 512, snr=5)   # a noisy doppler siganl 
par(mfrow=c(2,2)) 
plot(xx, type="l", xlab="") 
yy <- dwt(xx, wavelet="s8", boundary="periodic", n.levels=4) 
plot(yy) 
yy[c("d1","d2","d3")] <- 0     # set finer level coefficients 0 
x2 <- reconstruct(yy)          # reconstructed doppler 
plot(x2, type="l", xlab="") 
yy[["d4"]][-(6:9)] <- 0        # assign 0's to all but the 6-9th coefficients 
x3 <- reconstruct(yy)          # reconstructed doppler 
plot(x3, type="l", xlab="", ylab="")