Westerlund 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- westerlund-0.1.0/LICENSE +21 -0
- westerlund-0.1.0/PKG-INFO +77 -0
- westerlund-0.1.0/README.md +51 -0
- westerlund-0.1.0/pyproject.toml +36 -0
- westerlund-0.1.0/setup.cfg +4 -0
- westerlund-0.1.0/src/Westerlund/__init__.py +16 -0
- westerlund-0.1.0/src/Westerlund/main.py +1701 -0
- westerlund-0.1.0/src/Westerlund.egg-info/PKG-INFO +77 -0
- westerlund-0.1.0/src/Westerlund.egg-info/SOURCES.txt +10 -0
- westerlund-0.1.0/src/Westerlund.egg-info/dependency_links.txt +1 -0
- westerlund-0.1.0/src/Westerlund.egg-info/requires.txt +6 -0
- westerlund-0.1.0/src/Westerlund.egg-info/top_level.txt +1 -0
westerlund-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bosco Hung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: Westerlund
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Westerlund: Westerlund ECM Panel Cointegration Test.
|
|
5
|
+
Author-email: Bosco Hung <bosco.hung@st-annes.ox.ac.uk>
|
|
6
|
+
Project-URL: Homepage, https://github.com/bosco-hung/WesterlundTest
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/bosco-hung/WesterlundTest/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
15
|
+
Classifier: Topic :: Sociology
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy>=1.20.0
|
|
20
|
+
Requires-Dist: pandas>=1.3.0
|
|
21
|
+
Requires-Dist: statsmodels>=0.13.0
|
|
22
|
+
Requires-Dist: scipy>=1.7.0
|
|
23
|
+
Requires-Dist: matplotlib>=3.4.0
|
|
24
|
+
Requires-Dist: seaborn>=0.11.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# Westerlund: Panel Cointegration Testing in Python
|
|
28
|
+
|
|
29
|
+
`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.
|
|
30
|
+
|
|
31
|
+
## Key Features
|
|
32
|
+
|
|
33
|
+
The package replicates the logic of the Westerlund (2007) methodology, including:
|
|
34
|
+
* **Four Test Statistics**: Computes $G_t$, $G_a$, $P_t$, and $P_a$.
|
|
35
|
+
* **Flexible Dynamics**: Allows for unit-specific lag and lead lengths.
|
|
36
|
+
* **Automated Selection**: Built-in AIC/BIC selection logic for optimal lag and lead lengths.
|
|
37
|
+
* **Bootstrap Procedure**: Robust p-values to handle cross-sectional dependence.
|
|
38
|
+
* **Kernel Estimation**: Bartlett kernel long-run variance estimation.
|
|
39
|
+
* **Gap Handling**: Strict time-series continuity checks to ensure valid econometric results.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Usage Examples
|
|
44
|
+
```python
|
|
45
|
+
import pandas as pd
|
|
46
|
+
from westerlund_test import WesterlundTest
|
|
47
|
+
|
|
48
|
+
# 1. Prepare your panel data (Long format)
|
|
49
|
+
# Required columns: ID, Time, Y, X1, X2...
|
|
50
|
+
df = pd.read_csv("your_data.csv")
|
|
51
|
+
|
|
52
|
+
# 2. Initialize the test
|
|
53
|
+
test = WesterlundTest(
|
|
54
|
+
data=df,
|
|
55
|
+
y_var='log_gdp',
|
|
56
|
+
x_vars=['log_energy', 'log_capital'],
|
|
57
|
+
id_var='country_id',
|
|
58
|
+
time_var='year',
|
|
59
|
+
lags=(0, 2), # Auto-select lags between 0 and 2
|
|
60
|
+
leads=(0, 1), # Auto-select leads between 0 and 1
|
|
61
|
+
constant=True, # Include intercept
|
|
62
|
+
trend=True, # Include time trend
|
|
63
|
+
bootstrap=100, # Perform 100 bootstrap replications
|
|
64
|
+
seed=42
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# 3. Run the estimation
|
|
68
|
+
results = test.run()
|
|
69
|
+
|
|
70
|
+
# 4. Visualize the results
|
|
71
|
+
test.plot_bootstrap()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## References
|
|
75
|
+
Westerlund, J. (2007). Testing for Error Correction in Panel Data. Oxford Bulletin of Economics and Statistics, 69(6), 709-748.
|
|
76
|
+
|
|
77
|
+
Persyn, D., & Westerlund, J. (2008). Error-Correction-Based Cointegration Tests for Panel Data. Stata Journal, 8(2), 232-241.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Westerlund: Panel Cointegration Testing in Python
|
|
2
|
+
|
|
3
|
+
`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.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
The package replicates the logic of the Westerlund (2007) methodology, including:
|
|
8
|
+
* **Four Test Statistics**: Computes $G_t$, $G_a$, $P_t$, and $P_a$.
|
|
9
|
+
* **Flexible Dynamics**: Allows for unit-specific lag and lead lengths.
|
|
10
|
+
* **Automated Selection**: Built-in AIC/BIC selection logic for optimal lag and lead lengths.
|
|
11
|
+
* **Bootstrap Procedure**: Robust p-values to handle cross-sectional dependence.
|
|
12
|
+
* **Kernel Estimation**: Bartlett kernel long-run variance estimation.
|
|
13
|
+
* **Gap Handling**: Strict time-series continuity checks to ensure valid econometric results.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Usage Examples
|
|
18
|
+
```python
|
|
19
|
+
import pandas as pd
|
|
20
|
+
from westerlund_test import WesterlundTest
|
|
21
|
+
|
|
22
|
+
# 1. Prepare your panel data (Long format)
|
|
23
|
+
# Required columns: ID, Time, Y, X1, X2...
|
|
24
|
+
df = pd.read_csv("your_data.csv")
|
|
25
|
+
|
|
26
|
+
# 2. Initialize the test
|
|
27
|
+
test = WesterlundTest(
|
|
28
|
+
data=df,
|
|
29
|
+
y_var='log_gdp',
|
|
30
|
+
x_vars=['log_energy', 'log_capital'],
|
|
31
|
+
id_var='country_id',
|
|
32
|
+
time_var='year',
|
|
33
|
+
lags=(0, 2), # Auto-select lags between 0 and 2
|
|
34
|
+
leads=(0, 1), # Auto-select leads between 0 and 1
|
|
35
|
+
constant=True, # Include intercept
|
|
36
|
+
trend=True, # Include time trend
|
|
37
|
+
bootstrap=100, # Perform 100 bootstrap replications
|
|
38
|
+
seed=42
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# 3. Run the estimation
|
|
42
|
+
results = test.run()
|
|
43
|
+
|
|
44
|
+
# 4. Visualize the results
|
|
45
|
+
test.plot_bootstrap()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## References
|
|
49
|
+
Westerlund, J. (2007). Testing for Error Correction in Panel Data. Oxford Bulletin of Economics and Statistics, 69(6), 709-748.
|
|
50
|
+
|
|
51
|
+
Persyn, D., & Westerlund, J. (2008). Error-Correction-Based Cointegration Tests for Panel Data. Stata Journal, 8(2), 232-241.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "Westerlund"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Bosco Hung", email="bosco.hung@st-annes.ox.ac.uk" },
|
|
10
|
+
]
|
|
11
|
+
description = "Westerlund: Westerlund ECM Panel Cointegration Test."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Intended Audience :: Education",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
22
|
+
"Topic :: Sociology",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
dependencies = [
|
|
26
|
+
"numpy>=1.20.0",
|
|
27
|
+
"pandas>=1.3.0",
|
|
28
|
+
"statsmodels>=0.13.0",
|
|
29
|
+
"scipy>=1.7.0",
|
|
30
|
+
"matplotlib>=3.4.0",
|
|
31
|
+
"seaborn>=0.11.0"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
"Homepage" = "https://github.com/bosco-hung/WesterlundTest"
|
|
36
|
+
"Bug Tracker" = "https://github.com/bosco-hung/WesterlundTest/issues"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Westerlund: Westerlund ECM Panel Cointegration Test
|
|
3
|
+
=============================================
|
|
4
|
+
|
|
5
|
+
This package implements a functional approximation of the panel
|
|
6
|
+
cointegration tests proposed by Westerlund (2007). It computes
|
|
7
|
+
four statistics (Gt, Ga, Pt, Pa) based on unit-specific
|
|
8
|
+
error-correction models.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from .main import WesterlundTest
|
|
12
|
+
|
|
13
|
+
__all__ = ["Westerlund"]
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|
|
16
|
+
__author__ = "Bosco Hung"
|