Thresholds the detail coefficients of a Haar DWT using the Donoho-Johnstone
universal threshold sigma * sqrt(2 log n), with sigma estimated by the MAD
of the finest-scale details. The threshold is chosen so that with high
probability no pure-noise coefficient survives, so the shrinkage is
deliberately conservative – a smoother-than-expected fit is the method
working as designed.
Usage
morie_esl_wavelet_smooth(y, mode = "soft", threshold = NULL, levels = NULL)
Arguments
- y
Signal; padded to a power of two by reflection.
- mode
"soft" (biased toward zero, continuous) or "hard".
- threshold
Explicit lambda; defaults to the universal threshold.
- levels
Decomposition depth; defaults to the maximum.
Value
List with signal, threshold, sigma, coefficients,
n_zeroed, levels.
References
Donoho, D. L., & Johnstone, I. M. (1994). Ideal spatial
adaptation by wavelet shrinkage. Biometrika 81(3), 425-455.
Examples
if (requireNamespace("ranger", quietly = TRUE)) {
set.seed(1)
clean <- rep(c(0, 4, 1, -2), each = 64)
r <- morie_esl_wavelet_smooth(clean + rnorm(256, sd = 0.5))
mean((r$signal - clean)^2) < 0.25
}
#> [1] TRUE