segmcoint 1.0.0__py3-none-any.whl
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/__init__.py +103 -0
- segmcoint/kim2003.py +672 -0
- segmcoint/martins_rodrigues2022.py +783 -0
- segmcoint/simulation.py +333 -0
- segmcoint/utils.py +433 -0
- segmcoint-1.0.0.dist-info/METADATA +144 -0
- segmcoint-1.0.0.dist-info/RECORD +10 -0
- segmcoint-1.0.0.dist-info/WHEEL +5 -0
- segmcoint-1.0.0.dist-info/licenses/LICENSE +21 -0
- segmcoint-1.0.0.dist-info/top_level.txt +1 -0
segmcoint/__init__.py
ADDED
|
@@ -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
|
+
]
|