Learn R Programming

wavethresh (version 2.2-3)

threshold.imwd: Threshold an `imwd' Object (2D Wavelet)

Description

Applies hard or soft thresholding to wavelet decomposition object of class imwd.

Usage

threshold.imwd(imwd, levels=3:(wd$nlevels-1), type="hard",
    policy="universal", by.level=FALSE, value=0, dev=var,
    verbose=FALSE, return.threshold=FALSE, compression=T)

Arguments

imwd
object of class "imwd", typically from a wavelet decomposition using the imwd function.
levels
integer vector determining which levels are thresholded in the decomposition.
type
character, determining the type of thresholding; either "hard" or "soft".
policy
character indicating the threshold to use, can be "universal", "manual", or "probability".
by.level
logical; if FALSE then a global threshold is applied to all the levels specified by levels, otherwise a threshold is computed and applied separately to each level.
value
numeric user-supplied threshold for the "manual" policy, or the user-supplied quantile level for the "probability" policy.
dev
deviance function. The default var is to use the variance, but you can insert your own measure of deviance.
verbose
logical, if true then threshold() spurts informative messages at you.
return.threshold
logical, if true then the actual threshold is returned, otherwise the thresholded object is returned.
compression
logical; if true the thresholded object is compressed and then returned, otherwise it is returned unaltered.

Value

  • If compression==T then an object of class "imwdc" that has been thresholded and compressed is returned, otherwise an uncompressed, but thresholded, object of class "imwd" is returned.

RELEASE

Release 2.2 Copyright Guy Nason 1993

BUGS

There should be an optimal policy as well, although universal comes close.

Details

Thresholding modifies the coefficients within a imwd wavelet decomposition object. The modification can be performed either with a "hard" or "soft" thresholding selected by the "type" argument.

Hard thresholding simply compares a coefficient with a threshold. If it is larger in absolute magnitude it is left alone, if it is smaller it is set to zero. The "soft threshold" formula is

soft(w) = sgn(w)*max(|w| - t, 0)

where "w" is the wavelet coefficient, "t" is the threshold and "sgn" is the sign of w. Soft thresholding causes w to be replaced by soft(w).

There are many ways that the threshold can be computed, we term this the "policy". A universal policy computes a threshold based on Donoho and Johnstone's "universal thresholds". The threshold is sqrt(2*log(n))*noise, where noise is computed as sqrt(dev(w)), i.e. some measure of the variability of the coefficients, and n is the number of data points (or number of wavelet coefficients). By default "dev" is "var", so the noise level is estimated using the sample standard deviation. You can use any other such estimate by writing your own function and supplying it as the "dev" argument. For example you could create the function "myvar" by

myvar <- function(d) mad(d)^2

This computes the square of the mean absolute deviation of the data. It is squared because "dev" should be a measure on the variance scale, not the standard deviation (you know what I mean). If you make the "by.levels" argument T, then a separate threshold is computed for each level in the "levels" vector. This means that the variance is estimated separately for each level.

The "manual" policy is simple. You supply a threshold value ("value") and hard or soft thresholding is performed using that value. The "value" argument is a vector. If it is of length 1 then it is replicated to be the same length as the "levels" vector, otherwise it is repeated as many times as necessary to be the length vector's length. In this way, different thresholds can be given for different levels. Note that the "by.level" argument has no effect with this policy.

The "probability" policy works as follows. All coefficients that are smaller than the "value"th quantile of the coefficients are set to zero. If "by.level" is false, then the quantile is computed for all coefficients in the levels specified by the "levels" vector; if "by.level" is true, then each level's quantile is estimated separately.

The thresholding process forces many coefficients to zero. From release 2.2 onwards the thresholded "imwd" object is compressed by "compress" and returned as a much smaller "imwdc" object. An "imwdc" object is easily converted into an "imwd" object by "uncompress", but all relevant functions will handle the "imwdc" object.

Note that the coefficients for the horizontal, diagonal and vertical detail at a particular level are treated as one. In future releases we may add the capability to treat the details differently, although this would increase the complexity of the argument specification.

This function is a method for the generic function threshold() for class imwd. It can be invoked by calling threshold(x) for an object x of the appropriate class, or directly by calling threshold.imwd(x) regardless of the class of the object.

References

see wd for a list.

See Also

For examples, see imwr.imwd. imwr, imwd, compress, uncompress, imwd.object, imwdc.object