def test_model_combo_regi_error(self): #Columbus: reg = SP.GM_Combo_Regimes(self.y, self.X1, self.regimes, self.yd, self.q, w=self.w, regime_lag_sep=True, regime_err_sep=True) betas = np.array([[42.01035248], [-0.13938772], [-0.6528306], [0.54737621], [0.2684419], [34.02473255], [-0.14920259], [-0.48972903], [0.65883658], [-0.17174845]]) np.testing.assert_array_almost_equal(reg.betas, betas, 4) vm = np.array([ 153.58614432, 2.96302131, -3.26211855, -2.46914703, 0., 0., 0., 0. ]) np.testing.assert_array_almost_equal(reg.vm[0], vm, 4) u = np.array([7.73968703]) np.testing.assert_array_almost_equal(reg.u[0], u, 4) predy = np.array([7.98629297]) np.testing.assert_array_almost_equal(reg.predy[0], predy, 4) e = np.array([6.45052714]) np.testing.assert_array_almost_equal(reg.e_filtered[0], e, 4) chow_r = np.array([[1.00886404e-01, 7.50768497e-01], [3.61843271e-05, 9.95200481e-01], [4.69585772e-02, 8.28442711e-01], [8.13275259e-02, 7.75506385e-01]]) np.testing.assert_array_almost_equal(reg.chow.regi, chow_r, 4) chow_j = 0.28479988992843119 self.assertAlmostEqual(reg.chow.joint[0], chow_j) #Artficial: model = SP.GM_Combo_Regimes(self.y_a, self.x_a1, yend=self.x_a2, q=self.q_a, regimes=self.regi_a, w=self.w_a, regime_err_sep=True, regime_lag_sep=True) model1 = GM_Combo(self.y_a[0:(self.n2)].reshape((self.n2), 1), self.x_a1[0:(self.n2)], yend=self.x_a2[0:(self.n2)], q=self.q_a[0:(self.n2)], w=self.w_a1) model2 = GM_Combo(self.y_a[(self.n2):].reshape((self.n2), 1), self.x_a1[(self.n2):], yend=self.x_a2[(self.n2):], q=self.q_a[(self.n2):], w=self.w_a1) tbetas = np.vstack((model1.betas, model2.betas)) np.testing.assert_array_almost_equal(model.betas, tbetas) vm = np.hstack((model1.vm.diagonal(), model2.vm.diagonal()))
def test_model_combo(self): reg = SP.GM_Combo_Regimes(self.y, self.X1, self.regimes, self.yd, self.q, w=self.w) predy_e = np.array([18.82774339]) np.testing.assert_array_almost_equal(reg.predy_e[0], predy_e, 4) betas = np.array([[36.44798052], [-0.7974482], [30.53782661], [-0.72602806], [-0.30953121], [-0.21736652], [0.64801059], [-0.16601265]]) np.testing.assert_array_almost_equal(reg.betas, betas, 4) u = np.array([0.84393304]) np.testing.assert_array_almost_equal(reg.u[0], u, 4) e_filtered = np.array([0.4040027]) np.testing.assert_array_almost_equal(reg.e_filtered[0], e_filtered, 4) predy = np.array([14.88204696]) np.testing.assert_array_almost_equal(reg.predy[0], predy, 4) n = 49 self.assertAlmostEqual(reg.n, n) k = 7 self.assertAlmostEqual(reg.k, k) y = np.array([15.72598]) np.testing.assert_array_almost_equal(reg.y[0], y, 4) x = np.array([[0., 0., 1., 19.531]]) np.testing.assert_array_almost_equal(reg.x[0].toarray(), x, 4) yend = np.array([[0., 80.467003, 24.7142675]]) np.testing.assert_array_almost_equal(reg.yend[0].toarray(), yend, 4) z = np.array([[0., 0., 1., 19.531, 0., 80.467003, 24.7142675]]) np.testing.assert_array_almost_equal(reg.z[0].toarray(), z, 4) my = 35.128823897959187 self.assertAlmostEqual(reg.mean_y, my) sy = 16.732092091229699 self.assertAlmostEqual(reg.std_y, sy) vm = np.array([ 109.23549239, -0.19754121, 84.29574673, -1.99317178, -1.60123994, -0.1252719, -1.3930344 ]) np.testing.assert_array_almost_equal(reg.vm[0], vm, 4) sig2 = 94.98610921110007 self.assertAlmostEqual(reg.sig2, sig2, 4) pr2 = 0.6493586702255537 self.assertAlmostEqual(reg.pr2, pr2) pr2_e = 0.5255332447240576 self.assertAlmostEqual(reg.pr2_e, pr2_e) std_err = np.array([ 10.45157846, 0.93942923, 11.38484969, 0.60774708, 0.44461334, 0.15871227, 0.15738141 ]) np.testing.assert_array_almost_equal(reg.std_err, std_err, 4) chow_r = np.array([[0.49716076, 0.48075032], [0.00405377, 0.94923363], [0.03866684, 0.84411016]]) np.testing.assert_array_almost_equal(reg.chow.regi, chow_r, 4) chow_j = 0.64531386285872072 self.assertAlmostEqual(reg.chow.joint[0], chow_j)