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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file westerlund-0.1.0.tar.gz.
File metadata
- Download URL: westerlund-0.1.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faf327d289e6a48f2b39af206560b71fdb4b55ddb2c9663d39087d355af69ff1
|
|
| MD5 |
dfaea1f077e4bf5620858418e4433784
|
|
| BLAKE2b-256 |
b9c4049355d79cba16644c49d413eafc334f2868c155017e4d3eb2938246a97c
|
File details
Details for the file westerlund-0.1.0-py3-none-any.whl.
File metadata
- Download URL: westerlund-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87c059c9c1da22ca4fc5906485620d7a0482a89c3898ac9552236ede83e22e2c
|
|
| MD5 |
43c4dd942fddea697c50f67753bcf2da
|
|
| BLAKE2b-256 |
7acfeccd5f622af57fbee24c029ba5b7e0d5309e01e0bb2dbc245d96f55ead41
|