Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/statsmodels/tsa/coint_tables.py : 38%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2"""
3Created on Thu Aug 30 12:26:38 2012
4Author: Josef Perktold
7function jc = c_sja(n,p)
8% PURPOSE: find critical values for Johansen maximum eigenvalue statistic
9% ------------------------------------------------------------
10% USAGE: jc = c_sja(n,p)
11% where: n = dimension of the VAR system
12% p = order of time polynomial in the null-hypothesis
13% p = -1, no deterministic part
14% p = 0, for constant term
15% p = 1, for constant plus time-trend
16% p > 1 returns no critical values
17% ------------------------------------------------------------
18% RETURNS: a (3x1) vector of percentiles for the maximum eigenvalue
19% statistic for: [90% 95% 99%]
20% ------------------------------------------------------------
21% NOTES: for n > 12, the function returns a (3x1) vector of zeros.
22% The values returned by the function were generated using
23% a method described in MacKinnon (1996), using his FORTRAN
24% program johdist.f
25% ------------------------------------------------------------
26% SEE ALSO: johansen()
27% ------------------------------------------------------------
28% References: MacKinnon, Haug, Michelis (1996) 'Numerical distribution
29% functions of likelihood ratio tests for cointegration',
30% Queen's University Institute for Economic Research Discussion paper.
31% -------------------------------------------------------
32% written by:
33% James P. LeSage, Dept of Economics
34% University of Toledo
35% 2801 W. Bancroft St,
36% Toledo, OH 43606
37% jlesage@spatial-econometrics.com
39"""
41import numpy as np
43ss_ejcp0 = '''\
44 2.9762 4.1296 6.9406
45 9.4748 11.2246 15.0923
46 15.7175 17.7961 22.2519
47 21.8370 24.1592 29.0609
48 27.9160 30.4428 35.7359
49 33.9271 36.6301 42.2333
50 39.9085 42.7679 48.6606
51 45.8930 48.8795 55.0335
52 51.8528 54.9629 61.3449
53 57.7954 61.0404 67.6415
54 63.7248 67.0756 73.8856
55 69.6513 73.0946 80.0937'''
57ss_ejcp1 = '''\
58 2.7055 3.8415 6.6349
59 12.2971 14.2639 18.5200
60 18.8928 21.1314 25.8650
61 25.1236 27.5858 32.7172
62 31.2379 33.8777 39.3693
63 37.2786 40.0763 45.8662
64 43.2947 46.2299 52.3069
65 49.2855 52.3622 58.6634
66 55.2412 58.4332 64.9960
67 61.2041 64.5040 71.2525
68 67.1307 70.5392 77.4877
69 73.0563 76.5734 83.7105'''
71ss_ejcp2 = '''\
72 2.7055 3.8415 6.6349
73 15.0006 17.1481 21.7465
74 21.8731 24.2522 29.2631
75 28.2398 30.8151 36.1930
76 34.4202 37.1646 42.8612
77 40.5244 43.4183 49.4095
78 46.5583 49.5875 55.8171
79 52.5858 55.7302 62.1741
80 58.5316 61.8051 68.5030
81 64.5292 67.9040 74.7434
82 70.4630 73.9355 81.0678
83 76.4081 79.9878 87.2395'''
85ejcp0 = np.array(ss_ejcp0.split(),float).reshape(-1,3)
86ejcp1 = np.array(ss_ejcp1.split(),float).reshape(-1,3)
87ejcp2 = np.array(ss_ejcp2.split(),float).reshape(-1,3)
90def c_sja(n, p):
91 if ((p > 1) or (p < -1)):
92 jc = np.full(3, np.nan)
93 elif ((n > 12) or (n < 1)):
94 jc = np.full(3, np.nan)
95 elif p == -1:
96 jc = ejcp0[n-1,:]
97 elif p == 0:
98 jc = ejcp1[n-1,:]
99 elif p == 1:
100 jc = ejcp2[n-1,:]
102 return jc
105'''
106function jc = c_sjt(n,p)
107% PURPOSE: find critical values for Johansen trace statistic
108% ------------------------------------------------------------
109% USAGE: jc = c_sjt(n,p)
110% where: n = dimension of the VAR system
111% NOTE: routine does not work for n > 12
112% p = order of time polynomial in the null-hypothesis
113% p = -1, no deterministic part
114% p = 0, for constant term
115% p = 1, for constant plus time-trend
116% p > 1 returns no critical values
117% ------------------------------------------------------------
118% RETURNS: a (3x1) vector of percentiles for the trace
119% statistic for [90% 95% 99%]
120% ------------------------------------------------------------
121% NOTES: for n > 12, the function returns a (3x1) vector of zeros.
122% The values returned by the function were generated using
123% a method described in MacKinnon (1996), using his FORTRAN
124% program johdist.f
125% ------------------------------------------------------------
126% SEE ALSO: johansen()
127% ------------------------------------------------------------
128% % References: MacKinnon, Haug, Michelis (1996) 'Numerical distribution
129% functions of likelihood ratio tests for cointegration',
130% Queen's University Institute for Economic Research Discussion paper.
131% -------------------------------------------------------
132% written by:
133% James P. LeSage, Dept of Economics
134% University of Toledo
135% 2801 W. Bancroft St,
136% Toledo, OH 43606
137% jlesage@spatial-econometrics.com
138% these are the values from Johansen's 1995 book
139% for comparison to the MacKinnon values
140%jcp0 = [ 2.98 4.14 7.02
141% 10.35 12.21 16.16
142% 21.58 24.08 29.19
143% 36.58 39.71 46.00
144% 55.54 59.24 66.71
145% 78.30 86.36 91.12
146% 104.93 109.93 119.58
147% 135.16 140.74 151.70
148% 169.30 175.47 187.82
149% 207.21 214.07 226.95
150% 248.77 256.23 270.47
151% 293.83 301.95 318.14];
152%
153'''
156ss_tjcp0 = '''\
157 2.9762 4.1296 6.9406
158 10.4741 12.3212 16.3640
159 21.7781 24.2761 29.5147
160 37.0339 40.1749 46.5716
161 56.2839 60.0627 67.6367
162 79.5329 83.9383 92.7136
163 106.7351 111.7797 121.7375
164 137.9954 143.6691 154.7977
165 173.2292 179.5199 191.8122
166 212.4721 219.4051 232.8291
167 255.6732 263.2603 277.9962
168 302.9054 311.1288 326.9716'''
171ss_tjcp1 = '''\
172 2.7055 3.8415 6.6349
173 13.4294 15.4943 19.9349
174 27.0669 29.7961 35.4628
175 44.4929 47.8545 54.6815
176 65.8202 69.8189 77.8202
177 91.1090 95.7542 104.9637
178 120.3673 125.6185 135.9825
179 153.6341 159.5290 171.0905
180 190.8714 197.3772 210.0366
181 232.1030 239.2468 253.2526
182 277.3740 285.1402 300.2821
183 326.5354 334.9795 351.2150'''
185ss_tjcp2 = '''\
186 2.7055 3.8415 6.6349
187 16.1619 18.3985 23.1485
188 32.0645 35.0116 41.0815
189 51.6492 55.2459 62.5202
190 75.1027 79.3422 87.7748
191 102.4674 107.3429 116.9829
192 133.7852 139.2780 150.0778
193 169.0618 175.1584 187.1891
194 208.3582 215.1268 228.2226
195 251.6293 259.0267 273.3838
196 298.8836 306.8988 322.4264
197 350.1125 358.7190 375.3203'''
199tjcp0 = np.array(ss_tjcp0.split(),float).reshape(-1,3)
200tjcp1 = np.array(ss_tjcp1.split(),float).reshape(-1,3)
201tjcp2 = np.array(ss_tjcp2.split(),float).reshape(-1,3)
204def c_sjt(n, p):
205 if ((p > 1) or (p < -1)):
206 jc = np.full(3, np.nan)
207 elif ((n > 12) or (n < 1)):
208 jc = np.full(3, np.nan)
209 elif p == -1:
210 jc = tjcp0[n-1,:]
211 elif p == 0:
212 jc = tjcp1[n-1,:]
213 elif p == 1:
214 jc = tjcp2[n-1,:]
215 else:
216 raise ValueError('invalid p')
218 return jc
221if __name__ == '__main__':
222 for p in range(-2, 3, 1):
223 for n in range(12):
224 print(n, p)
225 print(c_sja(n, p))
226 print(c_sjt(n, p))