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

Moussa Keita

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.0.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.0-py3-none-any.whl (49.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wavenardl-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 df13244c4b12e4ea5e5212c7d8b39ee03440544d9964de1b01b0c5e0e222620e
MD5 31880ff79effb45f7fa1424ef1dd517e
BLAKE2b-256 568ddc47966aeb248ffad14405ea9e5c8c1d2f3045020abeeabb34b294b32413

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wavenardl-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47a8652c5a9a65255c18f4b574cfb480d16d5258e9a42c100172753cb4e11708
MD5 5f876edaa16608fe00882cefac39b588
BLAKE2b-256 a09180ef7ca0e4b13ad669c3410ca24eefbee02159158676e284e88e18ea84a2

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