def test_model(self): # Only spatial lag reg = SP.GM_Combo(self.y, self.X, w=self.w) e_reduced = np.array([28.18617481]) np.testing.assert_array_almost_equal(reg.e_pred[0], e_reduced, 6) predy_e = np.array([52.28082782]) np.testing.assert_array_almost_equal(reg.predy_e[0], predy_e, 6) betas = np.array([[57.61123515], [0.73441313], [-0.59459416], [-0.21762921], [0.54732051]]) np.testing.assert_array_almost_equal(reg.betas, betas, 6) u = np.array([25.57932637]) np.testing.assert_array_almost_equal(reg.u[0], u, 6) e_filtered = np.array([31.65374945]) np.testing.assert_array_almost_equal(reg.e_filtered[0], e_filtered, 5) predy = np.array([54.88767685]) np.testing.assert_array_almost_equal(reg.predy[0], predy, 6) n = 49 self.assertAlmostEqual(reg.n, n) k = 4 self.assertAlmostEqual(reg.k, k) y = np.array([80.467003]) np.testing.assert_array_almost_equal(reg.y[0], y, 6) x = np.array([1., 19.531, 15.72598]) np.testing.assert_array_almost_equal(reg.x[0], x, 6) yend = np.array([35.4585005]) np.testing.assert_array_almost_equal(reg.yend[0], yend, 6) z = np.array([1., 19.531, 15.72598, 35.4585005]) np.testing.assert_array_almost_equal(reg.z[0], z, 6) my = 38.43622446938776 self.assertAlmostEqual(reg.mean_y, my) sy = 18.466069465206047 self.assertAlmostEqual(reg.std_y, sy) vm = np.array( [[ 5.22438894e+02, -6.07257246e+00, -1.91428892e+00, -8.97134337e+00 ], [-6.07257218e+00, 2.38012839e-01, 4.70160773e-02, 2.80964005e-02], [-1.91428911e+00, 4.70160773e-02, 3.20924154e-02, 3.14968682e-03], [-8.97134237e+00, 2.80964005e-02, 3.14968682e-03, 2.15753890e-01]]) np.testing.assert_array_almost_equal(reg.vm, vm, 4) sig2 = 181.78650186468832 self.assertAlmostEqual(reg.sig2, sig2, 4) pr2 = 0.3018280166937799 self.assertAlmostEqual(reg.pr2, pr2) pr2_e = 0.3561355587000738 self.assertAlmostEqual(reg.pr2_e, pr2_e) std_err = np.array([22.85692222, 0.48786559, 0.17914356, 0.46449318]) np.testing.assert_array_almost_equal(reg.std_err, std_err, 5) z_stat = np.array([[2.52051597e+00, 1.17182922e-02], [1.50535954e+00, 1.32231664e-01], [-3.31909311e+00, 9.03103123e-04], [-4.68530506e-01, 6.39405261e-01]]) np.testing.assert_array_almost_equal(reg.z_stat, z_stat, 6)
def test_model(self): # Only spatial lag reg = SP.GM_Combo(self.y, self.X, w=self.w) e_reduced = np.array([28.18617481]) np.testing.assert_allclose(reg.e_pred[0], e_reduced, RTOL) predy_e = np.array([52.28082782]) np.testing.assert_allclose(reg.predy_e[0], predy_e, RTOL) betas = np.array([[57.61123515], [0.73441313], [-0.59459416], [-0.21762921], [0.54732051]]) np.testing.assert_allclose(reg.betas, betas, RTOL) u = np.array([25.57932637]) np.testing.assert_allclose(reg.u[0], u, RTOL) e_filtered = np.array([31.65374945]) np.testing.assert_allclose(reg.e_filtered[0], e_filtered, RTOL) predy = np.array([54.88767685]) np.testing.assert_allclose(reg.predy[0], predy, RTOL) n = 49 np.testing.assert_allclose(reg.n, n, RTOL) k = 4 np.testing.assert_allclose(reg.k, k, RTOL) y = np.array([80.467003]) np.testing.assert_allclose(reg.y[0], y, RTOL) x = np.array([1., 19.531, 15.72598]) np.testing.assert_allclose(reg.x.toarray()[0], x, RTOL) yend = np.array([35.4585005]) np.testing.assert_allclose(reg.yend[0], yend, RTOL) z = np.array([1., 19.531, 15.72598, 35.4585005]) np.testing.assert_allclose(reg.z.toarray()[0], z, RTOL) my = 38.43622446938776 np.testing.assert_allclose(reg.mean_y, my, RTOL) sy = 18.466069465206047 np.testing.assert_allclose(reg.std_y, sy, RTOL) vm = np.array([[522.43841148, -6.07256915, -1.91429117, -8.97133162], [-6.07256915, 0.23801287, 0.0470161, 0.02809628], [-1.91429117, 0.0470161, 0.03209242, 0.00314973], [-8.97133162, 0.02809628, 0.00314973, 0.21575363]]) #np.testing.assert_allclose(reg.vm,vm,RTOL) np.testing.assert_allclose(reg.vm, vm, RTOL) sig2 = 181.78650186468832 np.testing.assert_allclose(reg.sig2, sig2, RTOL) pr2 = 0.3018280166937799 np.testing.assert_allclose(reg.pr2, pr2, RTOL) pr2_e = 0.3561355587000738 np.testing.assert_allclose(reg.pr2_e, pr2_e, RTOL) std_err = np.array([22.85692222, 0.48786559, 0.17914356, 0.46449318]) np.testing.assert_allclose(reg.std_err, std_err, RTOL) z_stat = np.array([[2.52051597e+00, 1.17182922e-02], [1.50535954e+00, 1.32231664e-01], [-3.31909311e+00, 9.03103123e-04], [-4.68530506e-01, 6.39405261e-01]]) np.testing.assert_allclose(reg.z_stat, z_stat, RTOL)
def test_model(self): # Only spatial lag reg = SP.GM_Combo(self.y, self.X, w=self.w) e_reduced = np.array([28.18617481]) np.testing.assert_allclose(reg.e_pred[0], e_reduced, 4) predy_e = np.array([52.28082782]) np.testing.assert_allclose(reg.predy_e[0], predy_e, 4) betas = np.array([[57.61123515], [0.73441313], [-0.59459416], [-0.21762921], [0.54732051]]) np.testing.assert_allclose(reg.betas, betas, 4) u = np.array([25.57932637]) np.testing.assert_allclose(reg.u[0], u, 4) e_filtered = np.array([31.65374945]) np.testing.assert_allclose(reg.e_filtered[0], e_filtered, 4) predy = np.array([54.88767685]) np.testing.assert_allclose(reg.predy[0], predy, 4) n = 49 np.testing.assert_allclose(reg.n, n) k = 4 np.testing.assert_allclose(reg.k, k) y = np.array([80.467003]) np.testing.assert_allclose(reg.y[0], y, 4) x = np.array([1., 19.531, 15.72598]) np.testing.assert_allclose(reg.x[0], x, 4) yend = np.array([35.4585005]) np.testing.assert_allclose(reg.yend[0], yend, 4) z = np.array([1., 19.531, 15.72598, 35.4585005]) np.testing.assert_allclose(reg.z[0], z, 4) my = 38.43622446938776 np.testing.assert_allclose(reg.mean_y, my) sy = 18.466069465206047 np.testing.assert_allclose(reg.std_y, sy) vm = np.array( [5.22438333e+02, 2.38012875e-01, 3.20924173e-02, 2.15753579e-01]) np.testing.assert_allclose(np.diag(reg.vm), vm, 4) sig2 = 181.78650186468832 np.testing.assert_allclose(reg.sig2, sig2, 4) pr2 = 0.3018280166937799 np.testing.assert_allclose(reg.pr2, pr2, 4) pr2_e = 0.3561355586759414 np.testing.assert_allclose(reg.pr2_e, pr2_e, 4) std_err = np.array([22.85692222, 0.48786559, 0.17914356, 0.46449318]) np.testing.assert_allclose(reg.std_err, std_err, 4) z_stat = np.array([[2.52051597e+00, 1.17182922e-02], [1.50535954e+00, 1.32231664e-01], [-3.31909311e+00, 9.03103123e-04], [-4.68530506e-01, 6.39405261e-01]]) np.testing.assert_allclose(reg.z_stat, z_stat, 4)