\HeaderA{threshold.mwd}{Use threshold on an mwd object.}{threshold.mwd}
\keyword{smooth}{threshold.mwd}
\keyword{nonlinear}{threshold.mwd}
\begin{Description}\relax
Applies hard or soft thresholding to multiple wavelet decomposition object mwd.object.
\end{Description}
\begin{Usage}
\begin{verbatim}
threshold.mwd(mwd, levels = 3:(mwd$nlevels - 1), type = "hard",
        policy = "universal", boundary = FALSE, verbose = FALSE,
        return.threshold = FALSE, threshold = 0, covtol = 1e-09, 
        robust = TRUE, return.chisq = FALSE,
        bivariate = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{mwd}] The multiple wavelet decomposition object that you wish to threshold.
\item[\code{levels}] a vector of integers which determines which scale levels are thresholded in the decomposition. Each integer in the vector must refer to a valid level in the \code{\LinkA{mwd}{mwd}} object supplied. This is usually any integer from 0 to \code{\LinkA{nlevels}{nlevels}}(wd)-1 inclusive. Only the levels in this vector contribute to the computation of the threshold and its application. 
\item[\code{type}] determines the type of thresholding this can be "\code{hard}" or "\code{soft}".
\item[\code{policy}] selects the technique by which the threshold value is selected. Each policy corresponds to a method in the literature. At present the different policies are "\code{universal}", "\code{manual}", "\code{single}". The policies are described in detail below. 
\item[\code{boundary}] If this argument is \code{TRUE} then the boundary bookeeping values are included for thresholding, otherwise they are not. 
\item[\code{verbose}] if \code{TRUE} then the function prints out informative messages as it progresses. 
\item[\code{return.threshold}] If this option is \code{TRUE} then the actual \emph{value} of the threshold is returned. If this option is FALSE then a thresholded version of the input is returned.
\item[\code{threshold}] This argument conveys the user supplied threshold. If the \code{policy="manual"} then \code{value} is the actual threshold value. Any other \code{policy} means that the \code{threshold} value is ignored.
\item[\code{covtol}] The tolerance for what constitutes a singular variance matrix. If smallest eigenvalue of the estimated variance matrix is less than \code{covtol} then it is assumed to be singular and no thresholding is done at that level. Note: do not confuse \code{covtol} with \code{cvtol} an argument in \code{\LinkA{threshold.wd}{threshold.wd}}.
\item[\code{robust}] If TRUE the variance matrix at each level is estimated using a robust method (mad) otherwise it is estimated using var().
\item[\code{return.chisq}] If TRUE the vector of values to be thresholded is returned. These values are a quadratic form of each coefficient vector, and under normal assumptions the noise component will have a chi-squared distribution (see Downie and Silverman 1996). 
\item[\code{bivariate}] this line is in construction
\item[\code{...}] any other arguments
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Thresholding modifies the coefficients within a \code{\LinkA{mwd.object}{mwd.object}}. The modification can be performed either with a "hard" or "soft" thresholding selected by the type argument. 

Unless policy="single", the following method is applied. The columns of mwd$D are taken as coefficient vectors D_j,k. From these chisq_j,k=D_j,k . V_j^-1 . D_j,k is computed, where V_j^-1 is the inverse of the estimated variance of the coefficient vectors in that level (j). Chisq_j,k is a positive scalar which is to be thresholded in a similar manner to univariate hard or soft thresholding. To obtain the new values of D_j,k shrink the vector by the same proportion as was the corresponding chisq_j,k term.
\end{Details}
\begin{Value}
An object of class \code{\LinkA{mwd}{mwd}}. This object contains the thresholded wavelet coefficients. Note that if the \code{return.threshold} option is set to TRUE then the threshold values will be returned, or if \code{return.chisq} the vector of values to be thresholded will be returned, rather than the thresholded object.
\end{Value}
\begin{Section}{RELEASE}
Version 3.9.6 (Although Copyright Tim Downie 1995-6).
\end{Section}
\begin{SeeAlso}\relax
\code{\LinkA{accessC.mwd}{accessC.mwd}}, \code{\LinkA{accessD.mwd}{accessD.mwd}}, \code{\LinkA{draw.mwd}{draw.mwd}}, \code{\LinkA{mfirst.last}{mfirst.last}}, \code{\LinkA{mfilter.select}{mfilter.select}}, \code{\LinkA{mwd}{mwd}}, \code{\LinkA{mwd.object}{mwd.object}}, \code{\LinkA{mwr}{mwr}}, \code{\LinkA{plot.mwd}{plot.mwd}}, \code{\LinkA{print.mwd}{print.mwd}}, \code{\LinkA{putC.mwd}{putC.mwd}}, \code{\LinkA{putD.mwd}{putD.mwd}}, \code{\LinkA{summary.mwd}{summary.mwd}}, \code{\LinkA{wd}{wd}}, \code{\LinkA{wr.mwd}{wr.mwd}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}#
# Generate some test data
#
#test.data <- example.1()$y 
#ts.plot(test.data)
#
# Generate some noisy data
#
#ynoise <- test.data + rnorm(512, sd=0.1)
##
# Plot it
#
#ts.plot(ynoise)
#
# Now take the discrete multiple wavelet transform
# N.b. I have no idea if the default wavelets here are appropriate for
# this particular example. 
#
#ynmwd <- mwd(ynoise)
#plot(ynwd)
# [1] 2.020681 2.020681 2.020681 2.020681 2.020681 2.020681 2.020681
#
# Now do thresholding. We'll use the default arguments.
#
#ynmwdT <- threshold(ynmwd)
#
# And let's plot it
#
#plot(ynmwdT)
#
# Let us now see what the actual estimate looks like
#
#ymwr <- wr(ynmwdT)
#
# Here's the estimate... 
#
#ts.plot(ywr1)
\end{ExampleCode}
\end{Examples}

