Beispiel #1
0
 def setUp(self):
     self.guerry = pygeoda.open("./data/Guerry.shp")
     self.queen_w = pygeoda.queen_weights(self.guerry)
     self.crm_prp = self.guerry.GetIntegerCol("Crm_prp")
     self.litercy = self.guerry.GetIntegerCol("Litercy")
     slect_vars = ['Crm_prp','Crm_prs']
     self.data = [self.guerry.GetRealCol(v) for v in slect_vars]
Beispiel #2
0
    def test_local_multijoincount(self):
        columbus = pygeoda.open("./data/columbus.shp")
        columbus_q = pygeoda.queen_weights(columbus)
        nsa = columbus.GetRealCol("nsa")
        nsb = columbus.GetRealCol("nsb")
        nndata = (nsa, nsb)

        #The following two lines will raise warning to use local_bijoincount()
        #nsa_inv = [1-i for i in nsa]
        #lisa = pygeoda.local_multijoincount(columbus_q, (nsa, nsa_inv))

        lisa = pygeoda.local_multijoincount(columbus_q, nndata)

        lvals = lisa.lisa_values()
        self.assertEqual(lvals[0], 2)
        self.assertEqual(lvals[1], 3)
        self.assertEqual(lvals[2], 4)

        pvals = lisa.lisa_pvalues()
        self.assertEqual(pvals[0], 0.213000)
        self.assertEqual(pvals[1], 0.070000)
        self.assertEqual(pvals[2], 0.017000)

        nnvals = lisa.lisa_num_nbrs()
        self.assertEqual(nnvals[0], 2)
        self.assertEqual(nnvals[1], 3)
        self.assertEqual(nnvals[2], 4)
Beispiel #3
0
 def setUp(self):
     self.guerry = pygeoda.open("./data/Guerry.shp")
     self.queen_w = pygeoda.queen_weights(self.guerry)
     self.data = self.guerry[[
         "Crm_prs", "Crm_prp", "Litercy", "Donatns", "Infants", "Suicids"
     ]]
     self.bound_variable = self.guerry.GetRealCol("Pop1831")
     self.min_bound = 3236.67  # 10% of Pop1831
Beispiel #4
0
    def test_queen_weights(self):
        w = pygeoda.queen_weights(self.nat)

        self.assertEqual(w.num_obs, 3085)
        self.assertEqual(w.min_neighbors(), 1)
        self.assertEqual(w.mean_neighbors(), 5.8891410048622364)
        self.assertEqual(w.max_neighbors(), 14)
        self.assertTrue(w.is_symmetric())
        self.assertAlmostEqual(w.weights_sparsity(), 0.0019089598070866245)
Beispiel #5
0
 def setUp(self):
     self.guerry = pygeoda.open("./data/Guerry.shp")
     self.queen_w = pygeoda.queen_weights(self.guerry)
     select_vars = [
         "Crm_prs", "Crm_prp", "Litercy", "Donatns", "Infants", "Suicids"
     ]
     self.data = [self.guerry.GetRealCol(v) for v in select_vars]
     self.Crm_prs = self.guerry.GetRealCol('Crm_prs')
     self.Crm_prp = self.guerry.GetRealCol('Crm_prp')
Beispiel #6
0
    def test_queen2_weight(self):

        w = pygeoda.queen_weights(self.nat,
                                  order=2,
                                  include_lower_order=True,
                                  precision_threshold=1.0)

        self.assertEqual(w.num_obs, 3085)
        self.assertEqual(w.min_neighbors(), 2)
        self.assertEqual(w.mean_neighbors(), 18.574392220421394)
        self.assertEqual(w.max_neighbors(), 40)
        self.assertTrue(w.is_symmetric())
        self.assertAlmostEqual(w.weights_sparsity(), 0.006020872680849723)
Beispiel #7
0
    def test_local_bijoincount(self):
        columbus = pygeoda.open("./data/columbus.shp")
        columbus_q = pygeoda.queen_weights(columbus)
        nsa = columbus.GetRealCol("nsa")
        nsa_inv = [1-i for i in nsa]
        lisa = pygeoda.local_bijoincount(columbus_q, [nsa, nsa_inv])

        jc = lisa.lisa_values()
        self.assertEqual(jc[7], 0)
        self.assertEqual(jc[8], 1)
        self.assertEqual(jc[9], 1)

        pvals = lisa.lisa_pvalues()
        self.assertEqual(pvals[8], 0.002)
        self.assertEqual(pvals[9], 0.034)

        nn = lisa.lisa_num_nbrs()
        self.assertEqual(nn[0], 2)
        self.assertEqual(nn[1], 3)
        self.assertEqual(nn[2], 4)
Beispiel #8
0
    def test_local_joincount(self):
        columbus = pygeoda.open("./data/columbus.shp")
        columbus_q = pygeoda.queen_weights(columbus)
        nsa = columbus.GetRealCol("nsa")

        lisa = pygeoda.local_joincount(columbus_q, nsa)

        lvals = lisa.lisa_values()
        self.assertEqual(lvals[0], 2)
        self.assertEqual(lvals[1], 3)
        self.assertEqual(lvals[2], 4)

        pvals = lisa.lisa_pvalues()
        self.assertEqual(pvals[0], 0.21299999999999999)
        self.assertEqual(pvals[1], 0.070000000000000007)
        self.assertEqual(pvals[2], 0.017000000000000001)

        nnvals = lisa.lisa_num_nbrs()
        self.assertEqual(nnvals[0], 2)
        self.assertEqual(nnvals[1], 3)
        self.assertEqual(nnvals[2], 4)