*! version 1.1.0 2026-05-11

Title

lmodwt -- Maximal Overlap Discrete Wavelet Transform

Syntax

lmodwt varname [if] [in],
[levels(#)
filter(name)
mra
generate(prefix)
nodisplay]

Description

lmodwt computes the Maximal Overlap Discrete Wavelet Transform (MODWT)
of a time series variable. The MODWT is a non-decimated variant of the DWT
that produces N coefficients at each decomposition level (unlike the DWT
which downsamples by a factor of 2 at each level).

The MODWT is the standard tool for wavelet-based time series analysis in
economics and finance. It decomposes a time series into frequency bands
corresponding to different time horizons (e.g., short-run fluctuations
vs. long-run trends).

With the mra option, lmodwt also performs a Multiresolution
Analysis (MRA), decomposing the original signal into additive detail
(D1,...,DJ) and smooth (SJ) components that sum to the original series.

Note: This command is named lmodwt to avoid a naming clash with
the modwt built-in introduced in Stata 18.

Options

levels(#) specifies the number of decomposition levels J.
Default is 4. Maximum is floor(log2(N/(L-1)+1)) where L is the
filter length.

filter(name) specifies the wavelet filter. Default is la8
(Least Asymmetric, length 8). Available filters:

Daubechies: haar (d2), d4, d6, d8, d10, d12, d14, d16, d18, d20

Least Asym: la8, la10, la12, la14, la16, la18, la20

Best Local: bl14, bl18, bl20

Coiflet: c6, c12, c18, c24, c30

mra performs the Multiresolution Analysis and generates detail
and smooth component variables.

generate(prefix) specifies the prefix for generated MRA variables.
Default is _wv. Creates variables prefix_D1,...,prefix_DJ
and prefix_SJ.

nodisplay suppresses the results display.

Examples

Basic MODWT decomposition

. lmodwt gdp, levels(4) filter(la8)

MODWT with MRA and generated variables

. lmodwt gdp, levels(4) filter(haar) mra generate(_gdp)

. tsline _gdp_D1 _gdp_D2 _gdp_D3 _gdp_D4 _gdp_S4

Using Daubechies filter

. lmodwt returns, levels(6) filter(d10)

Stored results

lmodwt stores the following in e():

Scalars

e(N) number of observations

e(J) number of decomposition levels

e(L) maximum decomposition level for this filter/sample

Macros

e(cmd) lmodwt

e(varname) name of decomposed variable

e(filter) wavelet filter used

Matrices

e(Wj) wavelet coefficients at level j

e(VJ) final-level scaling coefficients (V is reserved by ereturn post)

e(wvar) wavelet variance per level

Also see

Help: wavelet, wmcorr, wt