Cointegration testing with structural breaks in very small samples (Python port of R package by Dr. Merwan Roudane, Independent Researcher)
Project description
cointsmall: Cointegration Testing with Structural Breaks in Very Small Samples
Python implementation of cointegration tests with endogenous structural breaks for very small sample sizes (T < 50) following Trinh (2022).
Overview
This package implements the methodology from:
Trinh, J. (2022). Testing for cointegration with structural changes in very small sample. THEMA Working Paper n°2022-01, CY Cergy Paris Université.
The package extends the Gregory-Hansen (1996) test to allow up to two structural breaks with size-corrected critical values computed via surface response methodology. It is designed for macroeconometric studies of emerging economies where data history is limited.
Features
- Size-corrected critical values for sample sizes as small as T=15
- Multiple model specifications: No breaks, breaks in intercept only, breaks in intercept and slope
- Up to 2 structural breaks with endogenous break date selection
- Composite testing procedure for automatic model selection
- Verified against paper: All critical values match Table 1 from Trinh (2022)
Installation
pip install cointsmall
Or install from source:
git clone https://github.com/yourusername/cointsmall-python.git
cd cointsmall-python
pip install -e .
Quick Start
import numpy as np
from cointsmall import composite_cointegration_test, test_cointegration_breaks
# Generate cointegrated data
np.random.seed(123)
T = 50
X = np.random.randn(T, 2)
Y = 2 + 1.5 * X[:, 0] + 0.8 * X[:, 1] + np.random.randn(T) * 0.5
# Test for cointegration using composite procedure
result = composite_cointegration_test(Y, X, max_breaks=2)
print(result)
print(result.summary())
Main Functions
test_cointegration_breaks()
Test for cointegration with a specific number of breaks:
# No breaks
result = test_cointegration_breaks(Y, X, n_breaks=0, model='o')
# One break in intercept and slope
result = test_cointegration_breaks(Y, X, n_breaks=1, model='cs')
# Two breaks in intercept only
result = test_cointegration_breaks(Y, X, n_breaks=2, model='c')
print(result)
composite_cointegration_test()
Automatic model selection across multiple specifications:
result = composite_cointegration_test(Y, X, max_breaks=2)
print(result.summary())
get_critical_value()
Get size-corrected critical values:
from cointsmall import get_critical_value
# T=30, m=1 regressor, 1 break in intercept and slope
cv = get_critical_value(T=30, m=1, b=1, model='cs')
print(f"Critical value: {cv}")
verify_critical_values()
Verify implementation against paper:
from cointsmall import verify_critical_values
# Should return True
is_valid = verify_critical_values()
print(f"Implementation valid: {is_valid}")
Model Specifications
- Model O: No structural breaks (standard cointegration test)
- Model C: Breaks in intercept only
- Model CS: Breaks in intercept and slope coefficients
Limitations
- Only 5% significance level is implemented (as in the paper)
- Maximum 3 regressors (m ≤ 3)
- Maximum 2 breaks (b ≤ 2)
- P-values are not computed (not provided in original paper)
Citation
When using this package, please cite:
Trinh, J. (2022). Testing for cointegration with structural changes in very
small sample. THEMA Working Paper n°2022-01, CY Cergy Paris Université.
And optionally cite the R package:
Roudane, M. (2025). cointsmall: R package for cointegration testing with
structural breaks in very small samples. R package version 0.1.1.
Author
- Methodology: Jérôme Trinh (jerome.trinh@ensae.fr)
- R Package: Dr. Merwan Roudane (merwanroudane920@gmail.com) - Independent Researcher
- Python Port: Based on R package version 0.1.1 by Dr. Merwan Roudane
References
- Gregory, A. W., & Hansen, B. E. (1996). Residual-based tests for cointegration in models with regime shifts. Journal of Econometrics, 70(1), 99-126.
- MacKinnon, J. G. (1991). Critical values for cointegration tests. In Long-Run Economic Relationships: Readings in Cointegration, Chapter 13.
- Trinh, J. (2022). Testing for cointegration with structural changes in very small sample. THEMA Working Paper n°2022-01, CY Cergy Paris Université.
License
GPL-3
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 cointsmall-0.1.0.tar.gz.
File metadata
- Download URL: cointsmall-0.1.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f96da987afca849c3bc6960f76c5b6a50d85969593a696e2a21d44a43c65fac0
|
|
| MD5 |
39626630c9386009e55d9f1489234907
|
|
| BLAKE2b-256 |
d4a3656e20dbb27651c07718251c235b82357a2c547a1bf4a3ae2c41702dbc73
|
File details
Details for the file cointsmall-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cointsmall-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3d1db482dfd93e4afdcbebcfbcd51ea2b9cd8170ab531722e37419e6bb6297
|
|
| MD5 |
2d28dae342da4b0c6981665f264cd8f2
|
|
| BLAKE2b-256 |
8fbf43f14ae4df560867cf8b60e226a4af48fd9341429c6e672f9be681dd0cd8
|