Example #1
0
 def test_model(self):
     # Only spatial lag
     yd2, q2 = pysal.spreg.utils.set_endog(self.y, self.X, self.w, None, None, 1, True)
     self.X = np.hstack((np.ones(self.y.shape),self.X))
     self.X = sparse.csr_matrix(self.X)
     reg = SP.BaseGM_Combo(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse)
     betas = np.array([[ 57.61123461],[  0.73441314], [ -0.59459416], [ -0.21762921], [  0.54732051]])
     np.testing.assert_array_almost_equal(reg.betas,betas,5)
     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.88767663])
     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.toarray()[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.toarray()[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.07257246e+00,   2.38012836e-01,   4.70160750e-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)
Example #2
0
 def test_model(self):
     # Only spatial lag
     yd2, q2 = pysal.spreg.utils.set_endog(self.y, self.X, self.w, None,
                                           None, 1, True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     self.X = sparse.csr_matrix(self.X)
     reg = SP.BaseGM_Combo(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse)
     betas = np.array([[57.61123461], [0.73441314], [-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.88767663])
     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)
     sig2 = 181.78650186468832
     np.testing.assert_allclose(reg.sig2, sig2, RTOL)
Example #3
0
 def test_model(self):
     # Only spatial lag
     yd2, q2 = pysal.spreg.utils.set_endog(self.y, self.X, self.w, None,
                                           None, 1, True)
     self.X = np.hstack((np.ones(self.y.shape), self.X))
     reg = SP.BaseGM_Combo(self.y, self.X, yend=yd2, q=q2, w=self.w.sparse)
     betas = np.array([[57.61123461], [0.73441314], [-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.88767663])
     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.22438365e+02, 2.38012873e-01, 3.20924172e-02, 2.15753599e-01])
     np.testing.assert_allclose(np.diag(reg.vm), vm, 4)
     sig2 = 181.78650186468832
     np.testing.assert_allclose(reg.sig2, sig2, 4)