Skip to main content

Westerlund: Westerlund ECM Panel Cointegration Test.

Project description

Westerlund: Panel Cointegration Testing in Python

Westerlund is a Python package implementing a functional approximation of the four panel cointegration tests developed by Westerlund (2007). The Westerlund test evaluates the null hypothesis of no cointegration by testing whether the error-correction term in a conditional panel ECM is equal to zero. If the null is rejected, there is evidence of a long-run equilibrium relationship between the variables.

Key Features

The package replicates the logic of the Westerlund (2007) methodology, including:

  • Four Test Statistics: Computes $G_t$, $G_a$, $P_t$, and $P_a$.
  • Flexible Dynamics: Allows for unit-specific lag and lead lengths.
  • Automated Selection: Built-in AIC/BIC selection logic for optimal lag and lead lengths.
  • Bootstrap Procedure: Robust p-values to handle cross-sectional dependence.
  • Kernel Estimation: Bartlett kernel long-run variance estimation.
  • Gap Handling: Strict time-series continuity checks to ensure valid econometric results.

Usage Examples

import pandas as pd
from westerlund_test import WesterlundTest

# 1. Prepare your panel data (Long format)
# Required columns: ID, Time, Y, X1, X2...
df = pd.read_csv("your_data.csv")

# 2. Initialize the test
test = WesterlundTest(
    data=df, 
    y_var='log_gdp', 
    x_vars=['log_energy', 'log_capital'], 
    id_var='country_id', 
    time_var='year',
    lags=(0, 2),        # Auto-select lags between 0 and 2
    leads=(0, 1),       # Auto-select leads between 0 and 1
    constant=True,      # Include intercept
    trend=True,         # Include time trend
    bootstrap=100,      # Perform 100 bootstrap replications
    seed=42
)

# 3. Run the estimation
results = test.run()

# 4. Visualize the results
test.plot_bootstrap()

References

Westerlund, J. (2007). Testing for Error Correction in Panel Data. Oxford Bulletin of Economics and Statistics, 69(6), 709-748.

Persyn, D., & Westerlund, J. (2008). Error-Correction-Based Cointegration Tests for Panel Data. Stata Journal, 8(2), 232-241.

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

westerlund-0.1.1.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

westerlund-0.1.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file westerlund-0.1.1.tar.gz.

File metadata

  • Download URL: westerlund-0.1.1.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.20

File hashes

Hashes for westerlund-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9de7ec24b500e12a98a872ec6032fe36509ea347240758dfbd449abf0e4cb129
MD5 62d6d436cef8b93f8077ffc1101acad9
BLAKE2b-256 743bb26813cee5822131cde783fde483ac105f122d6fa697c841f25905e31e1e

See more details on using hashes here.

File details

Details for the file westerlund-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: westerlund-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.20

File hashes

Hashes for westerlund-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a68e84832fb91de8f1f1e360e97ce0bd845d086585f6a01cbea8d2bc6bf202f3
MD5 df7fd96db8a6c7c6973895ec37247197
BLAKE2b-256 ac5940901fa4ca0345c6c69b605862c2e3483d13ff0c07df5eeefc19cc29cbbb

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