Tests for Segmented Cointegration: Kim (2003) and Martins & Rodrigues (2022)
Project description
segmcoint
Tests for Segmented Cointegration
A Python library implementing rigorous tests for segmented cointegration from two seminal econometric papers:
- Kim, J.-Y. (2003). Inference on Segmented Cointegration. Econometric Theory, 19, 620–639.
- Martins, L.F. and Rodrigues, P.M.M. (2022). Tests for Segmented Cointegration: An Application to US Governments Budgets. Empirical Economics, 63, 567–600.
Overview
Cointegration relations are often interpreted as long-run equilibrium relationships. In practice, however, real data frequently fail to confirm cointegration for well-understood economic relations. This package addresses the possibility that failure to confirm cointegration is due to nonstationary deviations in a relatively small portion of the data ("short-run"), while the cointegration relation prevails in the remaining periods—a situation called segmented cointegration.
Kim (2003) Tests
- Phillips–Perron–Ouliaris type tests: $Z^_\rho(\mathcal{C})$ and $Z^_t(\mathcal{C})$
- Augmented Dickey–Fuller type tests: $ADF^_\rho(\mathcal{C})$ and $ADF^_t(\mathcal{C})$
- Extremum estimator for break date identification (Eq. 3.16–3.17)
- Critical values from Tables 1 and 2 of the paper (for $\bar{\ell}(\mathcal{T}_N) = 0.3$)
Martins & Rodrigues (2022) Tests
- Wald-type statistics: $F_A(\tau, m^)$ and $F_B(\tau, m^)$ (Eq. 3.2)
- Supremum statistics: $\sup F_A(m^)$ and $\sup F_B(m^)$ (Eq. 3.3)
- Combined test: $W(m^*)$ (Eq. 3.4)
- Double maximum test: $W_{\max}$ (Eq. 3.5)
- Critical values from Table 1 of the paper
- Break date estimation (Remark 3)
Installation
pip install .
Or for development:
pip install -e ".[dev]"
Quick Start
import numpy as np
from segmcoint import kim_test, mr_test, generate_segmented_data
# Generate data with segmented cointegration
y, X, eps, info = generate_segmented_data(T=200, rho=0.85, seed=42)
# Kim (2003) tests
res_kim = kim_test(y, X, model='drift')
print(res_kim)
# Martins & Rodrigues (2022) tests
res_mr = mr_test(y, X, model='drift')
print(res_mr)
Model Specifications
Three deterministic specifications are supported, following Kim (2003, Eq. 2.1a–2.1c):
| Model | Equation | Kim (2003) | M&R (2022) |
|---|---|---|---|
'none' |
$x_{1t} = \beta' x_{2t} + \varepsilon_t$ | Case I | No det. |
'drift' |
$x_{1t} = \alpha + \beta' x_{2t} + \varepsilon_t$ | Case II | Intercept |
'trend' |
$x_{1t} = \alpha + \gamma t + \beta' x_{2t} + \varepsilon_t$ | Case III | Int.+Trend |
API Reference
kim_test(y, X, model, max_ell, step, ...)
Computes the infimum test statistics from Kim (2003). Returns a KimTestResult object.
mr_test(y, X, model, max_breaks, epsilon, step, ...)
Computes the Wald-type test statistics from Martins & Rodrigues (2022). Returns an MRTestResult object.
kim_break_estimator(y, X, model, max_ell, step)
Extremum estimator for the noncointegration period (Kim 2003, Eq. 3.16–3.17).
generate_segmented_data(T, beta, rho, ...)
Generate simulated data from a segmented cointegration DGP.
Testing
pytest tests/ -v
Author
Dr Merwan Roudane
Email: merwanroudane920@gmail.com
GitHub: https://github.com/merwanroudane/segmcoint
License
MIT License
References
- Kim, J.-Y. (2003). Inference on Segmented Cointegration. Econometric Theory, 19, 620–639.
- Martins, L.F. and Rodrigues, P.M.M. (2022). Tests for Segmented Cointegration: An Application to US Governments Budgets. Empirical Economics, 63, 567–600.
- Phillips, P.C.B. and Ouliaris, S. (1990). Asymptotic Properties of Residual Based Tests for Cointegration. Econometrica, 58, 165–193.
- Kejriwal, M., Perron, P., and Zhou, J. (2013). Wald Tests for Detecting Multiple Structural Changes in Persistence. Econometric Theory, 29, 289–323.
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 segmcoint-1.0.0.tar.gz.
File metadata
- Download URL: segmcoint-1.0.0.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b71a233b781aef223a4241ff70cabf2cabf793eb5b6162fe9b93a9634ffcf4dd
|
|
| MD5 |
d927b84c915051ab9a8b9671faf0cce2
|
|
| BLAKE2b-256 |
9cbdd8689123992f249c0312464028fe363dcd379d9c040eb38d44f2343600a4
|
File details
Details for the file segmcoint-1.0.0-py3-none-any.whl.
File metadata
- Download URL: segmcoint-1.0.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.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2e7aca220c1731cf790847a1d84ce7abc3bb29a74561f83b77846d73b15a1b
|
|
| MD5 |
b20e2afdc9750ec4c67d0d237aab4134
|
|
| BLAKE2b-256 |
4be4b23fc8fac68131c8c7039debb6e2639de6ef6ed69a426b4a40b3c3f87767
|