waveshrink(x, ..., shrink.rule=NULL, shrink.fun="soft", scale.rule=NULL, scale.fun="mad", p=2, smooth.levels=NULL, which.shrink=NULL, zero.crystal=NULL, n.top=NULL, vshrink=NULL, vscale=NULL, decimate=T)
wpt
or
cpt
(e.g., an outcome of
dwt, best.basis, best.level
).
wavelet, n.levels
,
for
dwt
(if
decimate=TRUE
) or
nd.dwt
(if
decimate=FALSE
). See
dwt
or
nd.dwt
for details.
In effect only when
x
is a numeric vector.
"adapt", "minimax", "sure", "top"
and
"universal"
.
See below for details. This argument will be ignored if argument
vshrink
is supplied.
"soft"
and
"hard"
are available. See
shrink
for details.
"all", "each"
and
crystal.name
. See details below.
This argument will be ignored if argument
vscale
is supplied.
"lp", "mad"
and
"sd"
. See details below.
This argument will be ignored if argument
vscale
is supplied.
scale.fun="lp"
.
n.levels-2
. This argument will be ignored if
x
is
a
wpt
or
cpt
object.
x
is a numeric vector or
dwt
object, the default is to shrink
all but the first coarsest levels; otherwise, the default is to shrink
all crystals.
n.top
is
specified,
shrink.rule
is set to
top
.
m=length(vshrink)
,
if
m=1
, all crystals use the same threshold;
if
m
is less than the number of crystals, the last
m
crystals will be
shrunk; if
m
is bigger than the number of crystals,
vshrink
is set to
`vshrink[1:m]'.
m=length(vscale)
,
if
m=1
, all crystals use the same scale;
if
m
is less than the number of crystals, the last
m
crystals will be
rescaled; if
m
is bigger than the number of crystals,
vscale
is set to
`vscale[1:m]'.
x
is a numeric vector.
"waveshrink"
,
"waveshrink.rts"
or
"waveshrink.ts"
with the same structure as input
x
and the original and the shrunk coefficients as attributes.
Available
shrink.rule
s:
a hybrid scheme, proposed by Donoho and Johnstone (1992b),
which combines the
universal
and
sure
(if the vector is not sparse),
see chapter "Nonparametric Estimation with Wavelets" of the
S+WAVELETS User's Manual
for details.
shrink.fun="hard"
) or shrink (if
shrink.fun="soft"
) the
n.top
number of largest coefficients and set all the other coefficients to zero.
This method is equivalent to using the
1-n.top/n
-th quantile as the
threshold, where
n
is the sample size. sqrt(2*log(n))
where
n
is the sample size.
The universal threshold is the default method and yields the largest threshold.
As a result, using universal threshold results in a relatively high degree of
smoothness. See Donoho and Johnstone (1992a) for more details.
scale.rule
s:
use all of the detail coefficients are used to estimate a single scale factor for all levels.
x
is a numeric vector or a
dwt
object, the default is
d1
, the
finest detail coefficients.
scale.fun
:
the usual
Lp
norm.
median(|x-median(x)|)/0.6745.
The S-PLUS function mad(x, center=0)
is called. sqrt(var(x))
.
Donoho, D. and Johnstone, I. (1992a). Ideal Spatial Adaptation by Wavelet
Shrinkage. Technical report, Department of Statistics, Stanford University.
Donoho, D. and Johnstone, I. (1992b). Adapting to Unknown Smoothness via Wavelet
Shrinkage. Technical report, Department of Statistics, Stanford University.
par(mfrow=c(1, 2)) xx <- make.signal("blocks", n=512, snr=7) plot(xx, type="l", xlab="noisy blocks", ylab="") yy <- waveshrink(xx, wavelet="d2") plot(yy, type="l", xlab="smoothed blocks", ylab="")