*! version 1.0.1 02jul2026

Title

wdenoise -- Haar "a trous" wavelet denoising of time series

Syntax

wdenoise
varlist
[if] [in]
[, options]

generate(stub) stub for the new denoised variables; default is
generate(dn)

replace overwrite the original variables instead

levels(#) number of decomposition levels J; default is
floor(log2(N))

threshold(string) soft (default) or hard
thresholding

nograph suppress the before/after graphs

Description

wdenoise denoises one or more series with the non-decimated Haar
"a trous" wavelet transform (HTW) of Murtagh, Starck & Renaud (2004):

s(j+1)(t) = 0.5*(s(j)(t - 2^j) + s(j)(t)),
d(j+1)(t) = s(j)(t) - s(j+1)(t)

The detail coefficients d(j) are thresholded with the Donoho (1995)
universal threshold lambda = sigma*sqrt(2*ln(N)), where sigma is the
median absolute deviation (MAD) of the level-1 details divided by
0.6745, and the series is reconstructed as the coarse smooth plus the
thresholded details. This is the denoising step of the wavelet-based
NARDL model of Jammazi, Lahiani & Nguyen (2015); see wavenardl.

By default a new variable stub_varname is created for
each input variable and a before/after graph is drawn.

Options

generate(stub) names the new denoised variables
stub_varname. Default stub is dn.

replace writes the denoised values back into the original
variables. May not be combined with generate().

levels(#) sets the number of decomposition levels J. The default
(0) uses floor(log2(N)); larger values are capped at floor(log2(N)).

threshold(string) chooses soft thresholding
(sign(d)*max(|d|-lambda,0), the default) or hard thresholding
(d*1{|d|>=lambda}).

nograph suppresses the before/after graphs.

Examples

. webuse lutkepohl2, clear

. wdenoise ln_inv ln_inc

. wdenoise ln_inv, generate(s) threshold(hard) levels(4)

. wdenoise ln_inv, replace nograph

Stored results

wdenoise stores the following in r() for each variable:

Scalars

r(J_var) number of decomposition levels used

r(sigma_var) estimated noise standard deviation

r(lambda_var) universal threshold

References

Donoho, D. L. (1995). De-noising by soft-thresholding.
IEEE Transactions on Information Theory, 41, 613-627.

Jammazi, R., Lahiani, A., & Nguyen, D. K. (2015). A wavelet-based
nonlinear ARDL model for assessing the exchange rate pass-through to
crude oil prices. Journal of International Financial Markets,
Institutions and Money, 34, 173-187.

Murtagh, F., Starck, J. L., & Renaud, O. (2004). On neuro-wavelet
modeling. Decision Support Systems, 37, 475-484.

Author

Dr Merwan Roudane

Independent Researcher

Email: merwanroudane920@gmail.com

GitHub: github.com/merwanroudane