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)
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.

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:

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".

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:
mra , mrd , nd.dwt , reconstruct , wave.filter , wavelet.options, crystal.vector.object , crystal.list.object .

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="")