Skip to content

Commit 8a1b074

Browse files
authored
Merge pull request statsmodels#5178 from bashtage/fix-arima-predict-test
TST: Fix scale in test
2 parents c2f6b08 + 18269cb commit 8a1b074

File tree

1 file changed

+40
-48
lines changed

1 file changed

+40
-48
lines changed

statsmodels/tsa/tests/test_arima.py

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,57 +2106,49 @@ def test_arima_diff2():
21062106

21072107
def test_arima111_predict_exog_2127():
21082108
# regression test for issue #2127
2109-
ef = [ 0.03005, 0.03917, 0.02828, 0.03644, 0.03379, 0.02744,
2110-
0.03343, 0.02621, 0.0305 , 0.02455, 0.03261, 0.03507,
2111-
0.02734, 0.05373, 0.02677, 0.03443, 0.03331, 0.02741,
2112-
0.03709, 0.02113, 0.03343, 0.02011, 0.03675, 0.03077,
2113-
0.02201, 0.04844, 0.05518, 0.03765, 0.05433, 0.03049,
2114-
0.04829, 0.02936, 0.04421, 0.02457, 0.04007, 0.03009,
2115-
0.04504, 0.05041, 0.03651, 0.02719, 0.04383, 0.02887,
2116-
0.0344 , 0.03348, 0.02364, 0.03496, 0.02549, 0.03284,
2117-
0.03523, 0.02579, 0.0308 , 0.01784, 0.03237, 0.02078,
2118-
0.03508, 0.03062, 0.02006, 0.02341, 0.02223, 0.03145,
2119-
0.03081, 0.0252 , 0.02683, 0.0172 , 0.02225, 0.01579,
2120-
0.02237, 0.02295, 0.0183 , 0.02356, 0.02051, 0.02932,
2121-
0.03025, 0.0239 , 0.02635, 0.01863, 0.02994, 0.01762,
2122-
0.02837, 0.02421, 0.01951, 0.02149, 0.02079, 0.02528,
2123-
0.02575, 0.01634, 0.02563, 0.01719, 0.02915, 0.01724,
2124-
0.02804, 0.0275 , 0.02099, 0.02522, 0.02422, 0.03254,
2125-
0.02095, 0.03241, 0.01867, 0.03998, 0.02212, 0.03034,
2126-
0.03419, 0.01866, 0.02623, 0.02052]
2127-
ue = [ 4.9, 5. , 5. , 5. , 4.9, 4.7, 4.8, 4.7, 4.7,
2128-
4.6, 4.6, 4.7, 4.7, 4.5, 4.4, 4.5, 4.4, 4.6,
2129-
4.5, 4.4, 4.5, 4.4, 4.6, 4.7, 4.6, 4.7, 4.7,
2130-
4.7, 5. , 5. , 4.9, 5.1, 5. , 5.4, 5.6, 5.8,
2131-
6.1, 6.1, 6.5, 6.8, 7.3, 7.8, 8.3, 8.7, 9. ,
2132-
9.4, 9.5, 9.5, 9.6, 9.8, 10. , 9.9, 9.9, 9.7,
2133-
9.8, 9.9, 9.9, 9.6, 9.4, 9.5, 9.5, 9.5, 9.5,
2134-
9.8, 9.4, 9.1, 9. , 9. , 9.1, 9. , 9.1, 9. ,
2135-
9. , 9. , 8.8, 8.6, 8.5, 8.2, 8.3, 8.2, 8.2,
2136-
8.2, 8.2, 8.2, 8.1, 7.8, 7.8, 7.8, 7.9, 7.9,
2137-
7.7, 7.5, 7.5, 7.5, 7.5, 7.3, 7.2, 7.2, 7.2,
2138-
7. , 6.7, 6.6, 6.7, 6.7, 6.3, 6.3]
2139-
2140-
# rescaling results in convergence failure
2141-
#model = sm.tsa.ARIMA(np.array(ef)*100, (1,1,1), exog=ue)
2142-
model = ARIMA(ef, (1,1,1), exog=ue)
2109+
ef = [0.03005, 0.03917, 0.02828, 0.03644, 0.03379, 0.02744,
2110+
0.03343, 0.02621, 0.03050, 0.02455, 0.03261, 0.03507,
2111+
0.02734, 0.05373, 0.02677, 0.03443, 0.03331, 0.02741,
2112+
0.03709, 0.02113, 0.03343, 0.02011, 0.03675, 0.03077,
2113+
0.02201, 0.04844, 0.05518, 0.03765, 0.05433, 0.03049,
2114+
0.04829, 0.02936, 0.04421, 0.02457, 0.04007, 0.03009,
2115+
0.04504, 0.05041, 0.03651, 0.02719, 0.04383, 0.02887,
2116+
0.03440, 0.03348, 0.02364, 0.03496, 0.02549, 0.03284,
2117+
0.03523, 0.02579, 0.03080, 0.01784, 0.03237, 0.02078,
2118+
0.03508, 0.03062, 0.02006, 0.02341, 0.02223, 0.03145,
2119+
0.03081, 0.02520, 0.02683, 0.01720, 0.02225, 0.01579,
2120+
0.02237, 0.02295, 0.01830, 0.02356, 0.02051, 0.02932,
2121+
0.03025, 0.02390, 0.02635, 0.01863, 0.02994, 0.01762,
2122+
0.02837, 0.02421, 0.01951, 0.02149, 0.02079, 0.02528,
2123+
0.02575, 0.01634, 0.02563, 0.01719, 0.02915, 0.01724,
2124+
0.02804, 0.02750, 0.02099, 0.02522, 0.02422, 0.03254,
2125+
0.02095, 0.03241, 0.01867, 0.03998, 0.02212, 0.03034,
2126+
0.03419, 0.01866, 0.02623, 0.02052]
2127+
ue = [4.9, 5.0, 5.0, 5.0, 4.9, 4.7, 4.8, 4.7, 4.7,
2128+
4.6, 4.6, 4.7, 4.7, 4.5, 4.4, 4.5, 4.4, 4.6,
2129+
4.5, 4.4, 4.5, 4.4, 4.6, 4.7, 4.6, 4.7, 4.7,
2130+
4.7, 5.0, 5.0, 4.9, 5.1, 5.0, 5.4, 5.6, 5.8,
2131+
6.1, 6.1, 6.5, 6.8, 7.3, 7.8, 8.3, 8.7, 9.0,
2132+
9.4, 9.5, 9.5, 9.6, 9.8, 10., 9.9, 9.9, 9.7,
2133+
9.8, 9.9, 9.9, 9.6, 9.4, 9.5, 9.5, 9.5, 9.5,
2134+
9.8, 9.4, 9.1, 9.0, 9.0, 9.1, 9.0, 9.1, 9.0,
2135+
9.0, 9.0, 8.8, 8.6, 8.5, 8.2, 8.3, 8.2, 8.2,
2136+
8.2, 8.2, 8.2, 8.1, 7.8, 7.8, 7.8, 7.9, 7.9,
2137+
7.7, 7.5, 7.5, 7.5, 7.5, 7.3, 7.2, 7.2, 7.2,
2138+
7.0, 6.7, 6.6, 6.7, 6.7, 6.3, 6.3]
2139+
2140+
ue = np.array(ue) / 100
2141+
model = ARIMA(ef, (1, 1, 1), exog=ue)
21432142
res = model.fit(transparams=False, pgtol=1e-8, iprint=0, disp=0)
2144-
assert_equal(res.mle_retvals['warnflag'], 0)
2145-
predicts = res.predict(start=len(ef), end = len(ef)+10,
2146-
exog=ue[-11:], typ = 'levels')
2143+
assert_equal(res.mle_retvals['warnflag'], 0)
2144+
predicts = res.predict(start=len(ef), end=len(ef) + 10,
2145+
exog=ue[-11:], typ='levels')
21472146

21482147
# regression test, not verified numbers
2149-
# if exog=ue in predict, which values are used ?
2150-
predicts_res = np.array(
2151-
[ 0.02612291, 0.02361929, 0.024966 , 0.02448193, 0.0248772 ,
2152-
0.0248762 , 0.02506319, 0.02516542, 0.02531214, 0.02544654,
2153-
0.02559099, 0.02550931])
2154-
2155-
# if exog=ue[-11:] in predict
2156-
predicts_res = np.array(
2157-
[ 0.02591112, 0.02321336, 0.02436593, 0.02368773, 0.02389767,
2158-
0.02372018, 0.02374833, 0.02367407, 0.0236443 , 0.02362868,
2159-
0.02362312])
2148+
predicts_res = np.array([
2149+
0.02591095, 0.02321325, 0.02436579, 0.02368759, 0.02389753,
2150+
0.02372, 0.0237481, 0.0236738, 0.023644, 0.0236283,
2151+
0.02362267])
21602152

21612153
assert_allclose(predicts, predicts_res, atol=5e-6)
21622154

0 commit comments

Comments
 (0)