def test_model_regi_error(self): #Artficial: model = SP.GM_Error_Hom_Regimes(self.y_a, self.x_a, self.regi_a, w=self.w_a, regime_err_sep=True, A1='het') model1 = GM_Error_Hom(self.y_a[0:(self.n2)].reshape((self.n2), 1), self.x_a[0:(self.n2)], w=self.w_a1, A1='het') model2 = GM_Error_Hom(self.y_a[(self.n2):].reshape((self.n2), 1), self.x_a[(self.n2):], w=self.w_a1, A1='het') 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())) np.testing.assert_array_almost_equal(model.vm.diagonal(), vm, 6) #Columbus: reg = SP.GM_Error_Hom_Regimes(self.y, self.X2, self.regimes, self.w, regime_err_sep=True, A1='het') betas = np.array([[60.66668194], [-1.72708492], [0.62170311], [61.4526885], [-1.90700858], [0.1102755]]) np.testing.assert_array_almost_equal(reg.betas, betas, 6) vm = np.array([45.57956967, -1.65365774, 0., 0., 0., 0.]) np.testing.assert_array_almost_equal(reg.vm[0], vm, 6) u = np.array([-8.48092392]) np.testing.assert_array_almost_equal(reg.u[0], u, 6) predy = np.array([24.20690392]) np.testing.assert_array_almost_equal(reg.predy[0], predy, 6) e = np.array([-8.33982604]) np.testing.assert_array_almost_equal(reg.e_filtered[0], e, 6) chow_r = np.array([[0.0050892, 0.94312823], [0.05746619, 0.81054651], [1.65677138, 0.19803981]]) np.testing.assert_array_almost_equal(reg.chow.regi, chow_r, 6) chow_j = 1.7914221673031792 self.assertAlmostEqual(reg.chow.joint[0], chow_j)
def test_model(self): reg = SP.GM_Error_Hom_Regimes(self.y, self.X, self.regimes, self.w, A1='het') betas = np.array([[62.95986466], [-0.15660795], [-1.49054832], [60.98577615], [-0.3358993], [-0.82129289], [0.54033921]]) np.testing.assert_array_almost_equal(reg.betas, betas, 6) u = np.array([-2.19031456]) np.testing.assert_array_almost_equal(reg.u[0], u, 6) predy = np.array([17.91629456]) np.testing.assert_array_almost_equal(reg.predy[0], predy, 6) n = 49 self.assertAlmostEqual(reg.n, n, 6) k = 6 self.assertAlmostEqual(reg.k, k, 6) y = np.array([15.72598]) np.testing.assert_array_almost_equal(reg.y[0], y, 6) x = np.array([[0., 0., 0., 1., 80.467003, 19.531]]) np.testing.assert_array_almost_equal(reg.x[0].toarray(), x, 6) e = np.array([2.72131648]) np.testing.assert_array_almost_equal(reg.e_filtered[0], e, 6) my = 35.128823897959187 self.assertAlmostEqual(reg.mean_y, my) sy = 16.732092091229699 self.assertAlmostEqual(reg.std_y, sy) vm = np.array([ 49.16245801, -0.12493165, -1.89294614, 5.71968257, -0.0571525, 0.05745855, 0. ]) np.testing.assert_array_almost_equal(reg.vm[0], vm, 6) sig2 = 96.96108341267626 self.assertAlmostEqual(reg.sig2, sig2, 5) pr2 = 0.5515791216023577 self.assertAlmostEqual(reg.pr2, pr2) std_err = np.array([ 7.01159454, 0.20701411, 0.56905515, 7.90537942, 0.10268949, 0.56660879, 0.15659504 ]) np.testing.assert_array_almost_equal(reg.std_err, std_err, 6) chow_r = np.array([[0.03888544, 0.84367579], [0.61613446, 0.43248738], [0.72632441, 0.39407719]]) np.testing.assert_array_almost_equal(reg.chow.regi, chow_r, 6) chow_j = 0.92133276766189676 self.assertAlmostEqual(reg.chow.joint[0], chow_j)