4949 EGARCH (),
5050]
5151
52+ ANALYTICAL_VOLATILITIES = [
53+ ConstantVariance (),
54+ GARCH (),
55+ FIGARCH (),
56+ EWMAVariance (lam = 0.94 ),
57+ MIDASHyperbolic (),
58+ HARCH (lags = [1 , 5 , 22 ]),
59+ RiskMetrics2006 (),
60+ ]
61+
62+
5263MODEL_SPECS = list (product (MEAN_MODELS , VOLATILITIES ))
64+ ANALYTICAL_MODEL_SPECS = list (product (MEAN_MODELS , ANALYTICAL_VOLATILITIES ))
5365
5466IDS = [
5567 f"{ str (mean ).split ('(' )[0 ]} -{ str (vol ).split ('(' )[0 ]} " for mean , vol in MODEL_SPECS
5668]
69+ ANALYTICAL_IDS = [
70+ f"{ str (mean ).split ('(' )[0 ]} -{ str (vol ).split ('(' )[0 ]} "
71+ for mean , vol in ANALYTICAL_MODEL_SPECS
72+ ]
5773
5874
5975@pytest .fixture (params = MODEL_SPECS , ids = IDS )
@@ -63,6 +79,13 @@ def model_spec(request):
6379 return mean
6480
6581
82+ @pytest .fixture (params = ANALYTICAL_MODEL_SPECS , ids = ANALYTICAL_IDS )
83+ def analytical_model_spec (request ):
84+ mean , vol = request .param
85+ mean .volatility = vol
86+ return mean
87+
88+
6689class TestForecasting :
6790 @classmethod
6891 def setup_class (cls ):
@@ -1053,3 +1076,31 @@ def test_rescale_ar():
10531076 fcasts = res .forecast (horizon = 100 ).variance
10541077 fcasts_no_rs = res_no_rs .forecast (horizon = 100 ).variance
10551078 assert_allclose (fcasts .iloc [0 , - 10 :], fcasts_no_rs .iloc [0 , - 10 :], rtol = 1e-5 )
1079+
1080+
1081+ def test_figarch_multistep ():
1082+ # GH 670
1083+ mod = ConstantMean (SP500 , volatility = FIGARCH ())
1084+ res = mod .fit (disp = "off" )
1085+ fcasts = res .forecast (horizon = 10 )
1086+ rv = fcasts .residual_variance
1087+ assert np .all (np .isfinite (rv ))
1088+ assert rv .shape == (1 , 10 )
1089+ fcasts_ri = res .forecast (horizon = 10 , reindex = True )
1090+ rv_ri = fcasts_ri .residual_variance
1091+ assert_frame_equal (rv , rv_ri .iloc [- 1 :])
1092+ assert rv_ri .shape == (SP500 .shape [0 ], 10 )
1093+
1094+
1095+ def test_multistep (analytical_model_spec ):
1096+ # GH 670
1097+ # Ensure all work as expected
1098+ res = analytical_model_spec .fit (disp = "off" )
1099+ fcasts = res .forecast (horizon = 10 )
1100+ rv = fcasts .residual_variance
1101+ assert np .all (np .isfinite (rv ))
1102+ assert rv .shape == (1 , 10 )
1103+ fcasts_ri = res .forecast (horizon = 10 , reindex = True )
1104+ rv_ri = fcasts_ri .residual_variance
1105+ assert_frame_equal (rv , rv_ri .iloc [- 1 :])
1106+ assert rv_ri .shape == (SP500 .shape [0 ], 10 )
0 commit comments