def test_model_endog_regi_error(self): #Columbus: reg = SP.GM_Endog_Error_Het_Regimes(self.y, self.X2, self.yd, self.q, self.regimes, self.w, regime_err_sep=True) betas = np.array([[7.92747424e+01], [5.78086230e+00], [-3.83173581e+00], [2.23210962e-01], [8.26255251e+01], [5.48294187e-01], [-1.28432891e+00], [3.57661629e-02]]) np.testing.assert_allclose(reg.betas, betas, RTOL) vm = np.array([ 7.55988579e+02, 2.53659722e+02, -1.34288316e+02, -2.66141766e-01, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00 ]) np.testing.assert_allclose(reg.vm[0], vm, RTOL) u = np.array([25.73781918]) np.testing.assert_allclose(reg.u[0], u, RTOL) predy = np.array([-10.01183918]) np.testing.assert_allclose(reg.predy[0], predy, RTOL) e = np.array([26.5449135]) np.testing.assert_allclose(reg.e_filtered[0], e, RTOL) chow_r = np.array([[0.00998573, 0.92040097], [0.12660165, 0.72198192], [0.12737281, 0.72117171], [0.43507956, 0.50950696]]) np.testing.assert_allclose(reg.chow.regi, chow_r, RTOL) chow_j = 1.3756768204399892 np.testing.assert_allclose(reg.chow.joint[0], chow_j, RTOL) #Artficial: model = SP.GM_Endog_Error_Het_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) model1 = GM_Endog_Error_Het(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_Endog_Error_Het(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_allclose(model.betas, tbetas, RTOL) vm = np.hstack((model1.vm.diagonal(), model2.vm.diagonal())) np.testing.assert_allclose(model.vm.diagonal(), vm, RTOL)
def test_model_endog(self): reg = SP.GM_Endog_Error_Het_Regimes(self.y, self.X2, self.yd, self.q, self.regimes, self.w) betas = np.array([[ 77.26679984], [ 4.45992905], [ 78.59534391], [ 0.41432319], [ -3.20196286], [ -1.13672283], [ 0.2174965 ]]) np.testing.assert_allclose(reg.betas,betas,RTOL) u = np.array([ 20.50716917]) np.testing.assert_allclose(reg.u[0],u,RTOL) e = np.array([ 25.13517175]) np.testing.assert_allclose(reg.e_filtered[0],e,RTOL) predy = np.array([-4.78118917]) np.testing.assert_allclose(reg.predy[0],predy,RTOL) n = 49 np.testing.assert_allclose(reg.n,n, RTOL) k = 6 np.testing.assert_allclose(reg.k,k, RTOL) y = np.array([ 15.72598]) np.testing.assert_allclose(reg.y[0],y,RTOL) x = np.array([[ 0. , 0. , 1. , 19.531]]) np.testing.assert_allclose(reg.x[0].toarray(),x,RTOL) yend = np.array([[ 0. , 80.467003]]) np.testing.assert_allclose(reg.yend[0].toarray(),yend,RTOL) z = np.array([[ 0. , 0. , 1. , 19.531 , 0. , 80.467003]]) np.testing.assert_allclose(reg.z[0].toarray(),z,RTOL) my = 35.128823897959187 np.testing.assert_allclose(reg.mean_y,my, RTOL) sy = 16.732092091229699 np.testing.assert_allclose(reg.std_y,sy, RTOL) vm = np.array([ 509.66122149, 150.5845341 , 9.64413821, 5.54782831, -80.95846045, -2.25308524, -3.2045214 ]) np.testing.assert_allclose(reg.vm[0],vm,RTOL) pr2 = 0.19776512679331681 np.testing.assert_allclose(reg.pr2,pr2) std_err = np.array([ 22.57567765, 11.34616946, 17.43881791, 1.30953812, 5.4830829 , 0.74634612, 0.29973079]) np.testing.assert_allclose(reg.std_err,std_err,RTOL) chow_r = np.array([[ 0.0022216 , 0.96240654], [ 0.13127347, 0.7171153 ], [ 0.14367307, 0.70465645]]) np.testing.assert_allclose(reg.chow.regi,chow_r,RTOL) chow_j = 1.2329971019087163 np.testing.assert_allclose(reg.chow.joint[0],chow_j, RTOL)