Exemplo n.º 1
0
 def test_moran(self):
     mi = moran.Moran(self.y, self.w, two_tailed=False)
     np.testing.assert_allclose(mi.I,
                                0.24365582621771659,
                                rtol=RTOL,
                                atol=ATOL)
     self.assertAlmostEqual(mi.p_norm, 0.00013573931385468807)
Exemplo n.º 2
0
 def test_sids(self):
     w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
     f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
     SIDR = np.array(f.by_col("SIDR74"))
     mi = moran.Moran(SIDR, w, two_tailed=False)
     np.testing.assert_allclose(mi.I,
                                0.24772519320480135,
                                atol=ATOL,
                                rtol=RTOL)
     self.assertAlmostEqual(mi.p_norm, 5.7916539074498452e-05)
Exemplo n.º 3
0
 def test_variance(self):
     y = np.arange(1, 10)
     w = libpysal.weights.util.lat2W(3, 3)
     mi = moran.Moran(y, w, transformation='B')
     np.testing.assert_allclose(mi.VI_rand,
                                0.059687500000000004,
                                atol=ATOL,
                                rtol=RTOL)
     np.testing.assert_allclose(mi.VI_norm,
                                0.053125000000000006,
                                atol=ATOL,
                                rtol=RTOL)
Exemplo n.º 4
0
 def test_sids(self):
     from esda import moran
     w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
     f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
     SIDR = np.array(f.by_col("SIDR74"))
     rho = moran.Moran(SIDR, w, two_tailed=False).I
     n = len(SIDR)
     k = int(n/2)       
     sm = Smaup(n, k, rho)
     np.testing.assert_allclose(sm.smaup,  0.15176796553181948, rtol=RTOL, atol=ATOL)
     self.assertAlmostEqual(sm.critical_01, 0.23404000000000003)
     self.assertAlmostEqual(sm.critical_05, 0.21088)
     self.assertAlmostEqual(sm.critical_1, 0.18239)
     self.assertEqual(sm.summary, 'Pseudo p-value > 0.10 (H0 is not rejected)')
Exemplo n.º 5
0
 def test_z_consistency(self):
     m1 = moran.Moran(self.y, self.w)
     # m2 = moran.Moran_BV(self.x, self.y, self.w) TODO testing for other.z values
     m3 = moran.Moran_Local(self.y, self.w)
     # m4 = moran.Moran_Local_BV(self.x, self.y, self.w)
     np.testing.assert_allclose(m1.z, m3.z, atol=ATOL, rtol=RTOL)