segmcoint 1.0.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.
- segmcoint-1.0.0/LICENSE +21 -0
- segmcoint-1.0.0/PKG-INFO +144 -0
- segmcoint-1.0.0/README.md +112 -0
- segmcoint-1.0.0/pyproject.toml +54 -0
- segmcoint-1.0.0/segmcoint/__init__.py +103 -0
- segmcoint-1.0.0/segmcoint/kim2003.py +672 -0
- segmcoint-1.0.0/segmcoint/martins_rodrigues2022.py +783 -0
- segmcoint-1.0.0/segmcoint/simulation.py +333 -0
- segmcoint-1.0.0/segmcoint/utils.py +433 -0
- segmcoint-1.0.0/segmcoint.egg-info/PKG-INFO +144 -0
- segmcoint-1.0.0/segmcoint.egg-info/SOURCES.txt +14 -0
- segmcoint-1.0.0/segmcoint.egg-info/dependency_links.txt +1 -0
- segmcoint-1.0.0/segmcoint.egg-info/requires.txt +8 -0
- segmcoint-1.0.0/segmcoint.egg-info/top_level.txt +1 -0
- segmcoint-1.0.0/setup.cfg +4 -0
- segmcoint-1.0.0/tests/test_segmcoint.py +349 -0
segmcoint-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dr Merwan Roudane
|
|
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.
|
segmcoint-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: segmcoint
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Tests for Segmented Cointegration: Kim (2003) and Martins & Rodrigues (2022)
|
|
5
|
+
Author-email: Dr Merwan Roudane <merwanroudane920@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/merwanroudane/segmcoint
|
|
8
|
+
Project-URL: Repository, https://github.com/merwanroudane/segmcoint
|
|
9
|
+
Project-URL: Issues, https://github.com/merwanroudane/segmcoint/issues
|
|
10
|
+
Keywords: cointegration,segmented cointegration,unit root,structural breaks,time series,econometrics
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.21
|
|
25
|
+
Requires-Dist: scipy>=1.7
|
|
26
|
+
Requires-Dist: pandas>=1.3
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
30
|
+
Requires-Dist: matplotlib>=3.5; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# segmcoint
|
|
34
|
+
|
|
35
|
+
**Tests for Segmented Cointegration**
|
|
36
|
+
|
|
37
|
+
[](https://www.python.org/downloads/)
|
|
38
|
+
[](https://opensource.org/licenses/MIT)
|
|
39
|
+
|
|
40
|
+
A Python library implementing rigorous tests for segmented cointegration from two seminal econometric papers:
|
|
41
|
+
|
|
42
|
+
1. **Kim, J.-Y. (2003)**. *Inference on Segmented Cointegration*. Econometric Theory, 19, 620–639.
|
|
43
|
+
2. **Martins, L.F. and Rodrigues, P.M.M. (2022)**. *Tests for Segmented Cointegration: An Application to US Governments Budgets*. Empirical Economics, 63, 567–600.
|
|
44
|
+
|
|
45
|
+
## Overview
|
|
46
|
+
|
|
47
|
+
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**.
|
|
48
|
+
|
|
49
|
+
### Kim (2003) Tests
|
|
50
|
+
|
|
51
|
+
- Phillips–Perron–Ouliaris type tests: $Z^*_\rho(\mathcal{C})$ and $Z^*_t(\mathcal{C})$
|
|
52
|
+
- Augmented Dickey–Fuller type tests: $ADF^*_\rho(\mathcal{C})$ and $ADF^*_t(\mathcal{C})$
|
|
53
|
+
- Extremum estimator for break date identification (Eq. 3.16–3.17)
|
|
54
|
+
- Critical values from Tables 1 and 2 of the paper (for $\bar{\ell}(\mathcal{T}_N) = 0.3$)
|
|
55
|
+
|
|
56
|
+
### Martins & Rodrigues (2022) Tests
|
|
57
|
+
|
|
58
|
+
- Wald-type statistics: $F_A(\tau, m^*)$ and $F_B(\tau, m^*)$ (Eq. 3.2)
|
|
59
|
+
- Supremum statistics: $\sup F_A(m^*)$ and $\sup F_B(m^*)$ (Eq. 3.3)
|
|
60
|
+
- Combined test: $W(m^*)$ (Eq. 3.4)
|
|
61
|
+
- Double maximum test: $W_{\max}$ (Eq. 3.5)
|
|
62
|
+
- Critical values from Table 1 of the paper
|
|
63
|
+
- Break date estimation (Remark 3)
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or for development:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install -e ".[dev]"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import numpy as np
|
|
81
|
+
from segmcoint import kim_test, mr_test, generate_segmented_data
|
|
82
|
+
|
|
83
|
+
# Generate data with segmented cointegration
|
|
84
|
+
y, X, eps, info = generate_segmented_data(T=200, rho=0.85, seed=42)
|
|
85
|
+
|
|
86
|
+
# Kim (2003) tests
|
|
87
|
+
res_kim = kim_test(y, X, model='drift')
|
|
88
|
+
print(res_kim)
|
|
89
|
+
|
|
90
|
+
# Martins & Rodrigues (2022) tests
|
|
91
|
+
res_mr = mr_test(y, X, model='drift')
|
|
92
|
+
print(res_mr)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Model Specifications
|
|
96
|
+
|
|
97
|
+
Three deterministic specifications are supported, following Kim (2003, Eq. 2.1a–2.1c):
|
|
98
|
+
|
|
99
|
+
| Model | Equation | Kim (2003) | M&R (2022) |
|
|
100
|
+
|----------|---------------------------------------------------------|------------|------------|
|
|
101
|
+
| `'none'` | $x_{1t} = \beta' x_{2t} + \varepsilon_t$ | Case I | No det. |
|
|
102
|
+
| `'drift'`| $x_{1t} = \alpha + \beta' x_{2t} + \varepsilon_t$ | Case II | Intercept |
|
|
103
|
+
| `'trend'`| $x_{1t} = \alpha + \gamma t + \beta' x_{2t} + \varepsilon_t$ | Case III | Int.+Trend |
|
|
104
|
+
|
|
105
|
+
## API Reference
|
|
106
|
+
|
|
107
|
+
### `kim_test(y, X, model, max_ell, step, ...)`
|
|
108
|
+
|
|
109
|
+
Computes the infimum test statistics from Kim (2003). Returns a `KimTestResult` object.
|
|
110
|
+
|
|
111
|
+
### `mr_test(y, X, model, max_breaks, epsilon, step, ...)`
|
|
112
|
+
|
|
113
|
+
Computes the Wald-type test statistics from Martins & Rodrigues (2022). Returns an `MRTestResult` object.
|
|
114
|
+
|
|
115
|
+
### `kim_break_estimator(y, X, model, max_ell, step)`
|
|
116
|
+
|
|
117
|
+
Extremum estimator for the noncointegration period (Kim 2003, Eq. 3.16–3.17).
|
|
118
|
+
|
|
119
|
+
### `generate_segmented_data(T, beta, rho, ...)`
|
|
120
|
+
|
|
121
|
+
Generate simulated data from a segmented cointegration DGP.
|
|
122
|
+
|
|
123
|
+
## Testing
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pytest tests/ -v
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Author
|
|
130
|
+
|
|
131
|
+
**Dr Merwan Roudane**
|
|
132
|
+
Email: merwanroudane920@gmail.com
|
|
133
|
+
GitHub: [https://github.com/merwanroudane/segmcoint](https://github.com/merwanroudane/segmcoint)
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT License
|
|
138
|
+
|
|
139
|
+
## References
|
|
140
|
+
|
|
141
|
+
- Kim, J.-Y. (2003). Inference on Segmented Cointegration. *Econometric Theory*, 19, 620–639.
|
|
142
|
+
- Martins, L.F. and Rodrigues, P.M.M. (2022). Tests for Segmented Cointegration: An Application to US Governments Budgets. *Empirical Economics*, 63, 567–600.
|
|
143
|
+
- Phillips, P.C.B. and Ouliaris, S. (1990). Asymptotic Properties of Residual Based Tests for Cointegration. *Econometrica*, 58, 165–193.
|
|
144
|
+
- Kejriwal, M., Perron, P., and Zhou, J. (2013). Wald Tests for Detecting Multiple Structural Changes in Persistence. *Econometric Theory*, 29, 289–323.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# segmcoint
|
|
2
|
+
|
|
3
|
+
**Tests for Segmented Cointegration**
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A Python library implementing rigorous tests for segmented cointegration from two seminal econometric papers:
|
|
9
|
+
|
|
10
|
+
1. **Kim, J.-Y. (2003)**. *Inference on Segmented Cointegration*. Econometric Theory, 19, 620–639.
|
|
11
|
+
2. **Martins, L.F. and Rodrigues, P.M.M. (2022)**. *Tests for Segmented Cointegration: An Application to US Governments Budgets*. Empirical Economics, 63, 567–600.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
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**.
|
|
16
|
+
|
|
17
|
+
### Kim (2003) Tests
|
|
18
|
+
|
|
19
|
+
- Phillips–Perron–Ouliaris type tests: $Z^*_\rho(\mathcal{C})$ and $Z^*_t(\mathcal{C})$
|
|
20
|
+
- Augmented Dickey–Fuller type tests: $ADF^*_\rho(\mathcal{C})$ and $ADF^*_t(\mathcal{C})$
|
|
21
|
+
- Extremum estimator for break date identification (Eq. 3.16–3.17)
|
|
22
|
+
- Critical values from Tables 1 and 2 of the paper (for $\bar{\ell}(\mathcal{T}_N) = 0.3$)
|
|
23
|
+
|
|
24
|
+
### Martins & Rodrigues (2022) Tests
|
|
25
|
+
|
|
26
|
+
- Wald-type statistics: $F_A(\tau, m^*)$ and $F_B(\tau, m^*)$ (Eq. 3.2)
|
|
27
|
+
- Supremum statistics: $\sup F_A(m^*)$ and $\sup F_B(m^*)$ (Eq. 3.3)
|
|
28
|
+
- Combined test: $W(m^*)$ (Eq. 3.4)
|
|
29
|
+
- Double maximum test: $W_{\max}$ (Eq. 3.5)
|
|
30
|
+
- Critical values from Table 1 of the paper
|
|
31
|
+
- Break date estimation (Remark 3)
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or for development:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e ".[dev]"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import numpy as np
|
|
49
|
+
from segmcoint import kim_test, mr_test, generate_segmented_data
|
|
50
|
+
|
|
51
|
+
# Generate data with segmented cointegration
|
|
52
|
+
y, X, eps, info = generate_segmented_data(T=200, rho=0.85, seed=42)
|
|
53
|
+
|
|
54
|
+
# Kim (2003) tests
|
|
55
|
+
res_kim = kim_test(y, X, model='drift')
|
|
56
|
+
print(res_kim)
|
|
57
|
+
|
|
58
|
+
# Martins & Rodrigues (2022) tests
|
|
59
|
+
res_mr = mr_test(y, X, model='drift')
|
|
60
|
+
print(res_mr)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Model Specifications
|
|
64
|
+
|
|
65
|
+
Three deterministic specifications are supported, following Kim (2003, Eq. 2.1a–2.1c):
|
|
66
|
+
|
|
67
|
+
| Model | Equation | Kim (2003) | M&R (2022) |
|
|
68
|
+
|----------|---------------------------------------------------------|------------|------------|
|
|
69
|
+
| `'none'` | $x_{1t} = \beta' x_{2t} + \varepsilon_t$ | Case I | No det. |
|
|
70
|
+
| `'drift'`| $x_{1t} = \alpha + \beta' x_{2t} + \varepsilon_t$ | Case II | Intercept |
|
|
71
|
+
| `'trend'`| $x_{1t} = \alpha + \gamma t + \beta' x_{2t} + \varepsilon_t$ | Case III | Int.+Trend |
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### `kim_test(y, X, model, max_ell, step, ...)`
|
|
76
|
+
|
|
77
|
+
Computes the infimum test statistics from Kim (2003). Returns a `KimTestResult` object.
|
|
78
|
+
|
|
79
|
+
### `mr_test(y, X, model, max_breaks, epsilon, step, ...)`
|
|
80
|
+
|
|
81
|
+
Computes the Wald-type test statistics from Martins & Rodrigues (2022). Returns an `MRTestResult` object.
|
|
82
|
+
|
|
83
|
+
### `kim_break_estimator(y, X, model, max_ell, step)`
|
|
84
|
+
|
|
85
|
+
Extremum estimator for the noncointegration period (Kim 2003, Eq. 3.16–3.17).
|
|
86
|
+
|
|
87
|
+
### `generate_segmented_data(T, beta, rho, ...)`
|
|
88
|
+
|
|
89
|
+
Generate simulated data from a segmented cointegration DGP.
|
|
90
|
+
|
|
91
|
+
## Testing
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pytest tests/ -v
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Author
|
|
98
|
+
|
|
99
|
+
**Dr Merwan Roudane**
|
|
100
|
+
Email: merwanroudane920@gmail.com
|
|
101
|
+
GitHub: [https://github.com/merwanroudane/segmcoint](https://github.com/merwanroudane/segmcoint)
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT License
|
|
106
|
+
|
|
107
|
+
## References
|
|
108
|
+
|
|
109
|
+
- Kim, J.-Y. (2003). Inference on Segmented Cointegration. *Econometric Theory*, 19, 620–639.
|
|
110
|
+
- Martins, L.F. and Rodrigues, P.M.M. (2022). Tests for Segmented Cointegration: An Application to US Governments Budgets. *Empirical Economics*, 63, 567–600.
|
|
111
|
+
- Phillips, P.C.B. and Ouliaris, S. (1990). Asymptotic Properties of Residual Based Tests for Cointegration. *Econometrica*, 58, 165–193.
|
|
112
|
+
- Kejriwal, M., Perron, P., and Zhou, J. (2013). Wald Tests for Detecting Multiple Structural Changes in Persistence. *Econometric Theory*, 29, 289–323.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "segmcoint"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Tests for Segmented Cointegration: Kim (2003) and Martins & Rodrigues (2022)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Dr Merwan Roudane", email = "merwanroudane920@gmail.com"},
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"cointegration",
|
|
17
|
+
"segmented cointegration",
|
|
18
|
+
"unit root",
|
|
19
|
+
"structural breaks",
|
|
20
|
+
"time series",
|
|
21
|
+
"econometrics",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Intended Audience :: Science/Research",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
33
|
+
"Topic :: Scientific/Engineering",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"numpy>=1.21",
|
|
37
|
+
"scipy>=1.7",
|
|
38
|
+
"pandas>=1.3",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=7.0",
|
|
44
|
+
"pytest-cov>=4.0",
|
|
45
|
+
"matplotlib>=3.5",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/merwanroudane/segmcoint"
|
|
50
|
+
Repository = "https://github.com/merwanroudane/segmcoint"
|
|
51
|
+
Issues = "https://github.com/merwanroudane/segmcoint/issues"
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
include = ["segmcoint*"]
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""
|
|
2
|
+
segmcoint: Tests for Segmented Cointegration
|
|
3
|
+
=============================================
|
|
4
|
+
|
|
5
|
+
A Python library implementing tests for segmented cointegration from:
|
|
6
|
+
|
|
7
|
+
1. Kim, J.-Y. (2003). Inference on Segmented Cointegration.
|
|
8
|
+
Econometric Theory, 19, 620-639.
|
|
9
|
+
|
|
10
|
+
2. Martins, L.F. and Rodrigues, P.M.M. (2022). Tests for Segmented
|
|
11
|
+
Cointegration: An Application to US Governments Budgets.
|
|
12
|
+
Empirical Economics, 63, 567-600.
|
|
13
|
+
|
|
14
|
+
Main Functions
|
|
15
|
+
--------------
|
|
16
|
+
kim_test :
|
|
17
|
+
Kim (2003) infimum-based tests for segmented cointegration.
|
|
18
|
+
Computes Z*_rho, Z*_t, ADF*_rho, ADF*_t statistics.
|
|
19
|
+
|
|
20
|
+
mr_test :
|
|
21
|
+
Martins & Rodrigues (2022) Wald-type tests for segmented cointegration.
|
|
22
|
+
Computes W(m*) and W_max statistics.
|
|
23
|
+
|
|
24
|
+
kim_break_estimator :
|
|
25
|
+
Extremum estimator for the noncointegration period (Kim 2003, Eq. 3.16-3.17).
|
|
26
|
+
|
|
27
|
+
Utility Functions
|
|
28
|
+
-----------------
|
|
29
|
+
generate_segmented_data :
|
|
30
|
+
Generate simulated data from a segmented cointegration DGP.
|
|
31
|
+
|
|
32
|
+
simulate_kim_critical_values :
|
|
33
|
+
Monte Carlo simulation of critical values for Kim (2003) tests.
|
|
34
|
+
|
|
35
|
+
simulate_mr_critical_values :
|
|
36
|
+
Monte Carlo simulation of critical values for Martins & Rodrigues (2022) tests.
|
|
37
|
+
|
|
38
|
+
monte_carlo_size_power :
|
|
39
|
+
Size and power analysis for both test procedures.
|
|
40
|
+
|
|
41
|
+
Example
|
|
42
|
+
-------
|
|
43
|
+
>>> import numpy as np
|
|
44
|
+
>>> from segmcoint import kim_test, mr_test, generate_segmented_data
|
|
45
|
+
>>>
|
|
46
|
+
>>> # Generate segmented cointegration data
|
|
47
|
+
>>> y, X, eps, info = generate_segmented_data(T=200, rho=0.85, seed=42)
|
|
48
|
+
>>>
|
|
49
|
+
>>> # Kim (2003) tests
|
|
50
|
+
>>> res_kim = kim_test(y, X, model='drift')
|
|
51
|
+
>>> print(res_kim)
|
|
52
|
+
>>>
|
|
53
|
+
>>> # Martins & Rodrigues (2022) tests
|
|
54
|
+
>>> res_mr = mr_test(y, X, model='drift')
|
|
55
|
+
>>> print(res_mr)
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
__version__ = "1.0.0"
|
|
59
|
+
__author__ = "Dr Merwan Roudane"
|
|
60
|
+
__email__ = "merwanroudane920@gmail.com"
|
|
61
|
+
|
|
62
|
+
from .kim2003 import (
|
|
63
|
+
kim_test,
|
|
64
|
+
kim_break_estimator,
|
|
65
|
+
get_critical_value,
|
|
66
|
+
KimTestResult,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
from .martins_rodrigues2022 import (
|
|
70
|
+
mr_test,
|
|
71
|
+
get_mr_critical_value,
|
|
72
|
+
MRTestResult,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
from .utils import (
|
|
76
|
+
ols_residuals,
|
|
77
|
+
generate_segmented_data,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
from .simulation import (
|
|
81
|
+
simulate_kim_critical_values,
|
|
82
|
+
simulate_mr_critical_values,
|
|
83
|
+
monte_carlo_size_power,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
__all__ = [
|
|
87
|
+
# Kim (2003)
|
|
88
|
+
"kim_test",
|
|
89
|
+
"kim_break_estimator",
|
|
90
|
+
"get_critical_value",
|
|
91
|
+
"KimTestResult",
|
|
92
|
+
# Martins & Rodrigues (2022)
|
|
93
|
+
"mr_test",
|
|
94
|
+
"get_mr_critical_value",
|
|
95
|
+
"MRTestResult",
|
|
96
|
+
# Utilities
|
|
97
|
+
"ols_residuals",
|
|
98
|
+
"generate_segmented_data",
|
|
99
|
+
# Simulation
|
|
100
|
+
"simulate_kim_critical_values",
|
|
101
|
+
"simulate_mr_critical_values",
|
|
102
|
+
"monte_carlo_size_power",
|
|
103
|
+
]
|