Skip to main content

Wavelet-based Nonlinear Autoregressive Distributed Lag (W-NARDL) model for Python

Project description

wavenardl

Wavelet-based Nonlinear Autoregressive Distributed Lag (W-NARDL) for Python

Python 3.9+ License: MIT

The first Python implementation of both standard NARDL and Wavelet-based NARDL models. This library provides a complete econometric toolkit for asymmetric cointegration analysis with wavelet denoising.

Features

Core Models

  • NARDL — Nonlinear ARDL with short-run and long-run asymmetry (Shin et al., 2014)
  • Wavelet NARDL — HTW wavelet-denoised NARDL (Jammazi et al., 2015)
  • ARDL — Standard linear ARDL as a special case

Wavelet Methods

  • Haar à Trous Wavelet (HTW) — Non-decimated transform from the paper
  • PyWavelets Integration — SWT, DWT with any wavelet family
  • Donoho Thresholding — Universal soft/hard threshold denoising

Statistical Tests

  • PSS Bounds F-test — Pesaran, Shin & Smith (2001) with Cases I–V
  • Narayan Test — Small-sample critical values (Narayan, 2005)
  • Symmetry Tests — Wald tests for long-run and short-run asymmetry
  • Diagnostics — Breusch-Godfrey, Breusch-Pagan, Jarque-Bera, RESET, CUSUM

Analysis Tools

  • Dynamic Multipliers — Cumulative multiplier curves with bootstrap CI
  • Long-run Coefficients — Delta method standard errors
  • Error Correction Model — Two-step ECM estimation
  • Automatic Lag Selection — Grid search, quick search (AIC/BIC/HQ)

Output & Visualization

  • Publication Tables — LaTeX, HTML, and rich console output
  • Wavelet Plots — Decomposition, scalogram heatmaps
  • Multiplier Plots — Positive/negative effects with CI bands
  • Diagnostic Plots — Residuals, Q-Q, ACF, CUSUM panels

Installation

pip install wavenardl

Or from source:

git clone https://github.com/mkeita/wavenardl.git
cd wavenardl
pip install -e .

Quick Start

Standard NARDL

from wavenardl import NARDL, pss_f_test, symmetry_test

import pandas as pd
data = pd.read_csv('my_data.csv')

# Estimate NARDL with asymmetric exchange rate effects
model = NARDL(
    data=data,
    formula="oil ~ exrate + cpi + Asymmetric(exrate) + deterministic(crisis)",
    maxlag=4,
    criterion='BIC'
)
results = model.fit(mode='grid')
results.summary()

# Cointegration test
pss = pss_f_test(results, case=3)
print(pss)

# Symmetry test
sym = symmetry_test(results)
print(sym)

Wavelet NARDL

from wavenardl import WaveletNARDL

# Fit W-NARDL with HTW denoising (as in the paper)
wmodel = WaveletNARDL(
    data=data,
    formula="oil ~ exrate + Asymmetric(exrate)",
    maxlag=4,
    wavelet_method='htw',  # Haar à Trous from the paper
    n_levels=4
)
results = wmodel.fit(fit_original=True)

# Compare original vs wavelet-denoised NARDL
results['comparison'].summary()

Dynamic Multipliers

from wavenardl import DynamicMultipliers, bootstrap_multipliers, plot_multipliers

# Compute multipliers
dm = DynamicMultipliers(results, horizon=40)
dm.summary()

# Bootstrap confidence intervals
mpsi = bootstrap_multipliers(results, horizon=40, replications=500, confidence_level=95)

# Plot
plot_multipliers(mpsi, variable='exrate', dep_var='oil')

Wavelet Visualization

from wavenardl import HaarATrousWavelet, plot_wavelet_decomposition, plot_scalogram

htw = HaarATrousWavelet(n_levels=6)
analysis = htw.full_analysis(data['oil'].values, name='Oil Price')

# Decomposition plot (paper Fig. 1 style)
plot_wavelet_decomposition(analysis)

# Scalogram heatmap
plot_scalogram(analysis, cmap='magma')

Publication Tables

from wavenardl import summary_table, comparison_table

# LaTeX table for journal submission
latex = summary_table(results, format='latex')
print(latex)

# HTML table for reports
html = summary_table(results, format='html')

Formula Syntax

The formula interface supports R-like specifications:

Formula Element Description
y ~ x1 + x2 Standard ARDL
Asymmetric(x1) or asym(x1) Both LR and SR asymmetry
Lasymmetric(x1) Long-run only asymmetry
Sasymmetric(x1) Short-run only asymmetry
deterministic(d1 + d2) Exogenous / dummy variables
trend Linear time trend
-1 No intercept

Dependencies

  • NumPy, Pandas, SciPy, Statsmodels
  • PyWavelets (pywt)
  • Matplotlib
  • Rich, Tabulate

References

  • 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.

  • Shin, Y., Yu, B., & Greenwood-Nimmo, M. (2014). Modelling asymmetric cointegration and dynamic multipliers in a nonlinear ARDL framework. Festschrift in Honor of Peter Schmidt, 281-314.

  • Pesaran, M. H., Shin, Y., & Smith, R. (2001). Bounds testing approaches to the analysis of level relationship. Journal of Applied Econometrics, 16(3), 289-326.

  • Narayan, P. K. (2005). The saving and investment nexus for China. Applied Economics, 37(17), 1979-1990.

Author

Dr Merwan Roudane

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wavenardl-1.0.1.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wavenardl-1.0.1-py3-none-any.whl (49.1 kB view details)

Uploaded Python 3

File details

Details for the file wavenardl-1.0.1.tar.gz.

File metadata

  • Download URL: wavenardl-1.0.1.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for wavenardl-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4400b9fd8bfdaf45a857edad8c80874112f0989639cc64345896008bbe2126a3
MD5 60da886635bdeef45b3cb050fc3b1fab
BLAKE2b-256 e7c0c31deed5c93683f6137af598a103eda2fa28721734e433f4884195df45bc

See more details on using hashes here.

File details

Details for the file wavenardl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: wavenardl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 49.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for wavenardl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a488f13444c04b1ea358cb563116dc12a674d928a7cef1b2a647e7a9924b25f2
MD5 ea3743e16d0d088dbbe2190de0f029a9
BLAKE2b-256 8735f8fbe3498355be84856b3b34f56318585b1d983bce45682aa498bd79abab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page