예제 #1
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     lm = moran.Moran_Local_Rate.by_col(df, ['SID79'], ['BIR79'], w=self.w,
                                        outvals=['p_z_sim', 'z_sim'],
                                        transformation='r', permutations=99)
     self.assertAlmostEqual(lm['SID79-BIR79_z_sim'][0],  -0.13699844503985936, 7)
     self.assertAlmostEqual(lm['SID79-BIR79_p_z_sim'][0], 0.44551601210081715)
예제 #2
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     mi = moran.Moran_Rate.by_col(df, ['SID79'], ['BIR79'], w=self.w, two_tailed=False)
     sidr = np.unique(mi["SID79-BIR79_moran_rate"].values)
     pval = np.unique(mi["SID79-BIR79_p_sim"].values)
     np.testing.assert_allclose(sidr, 0.16622343552567395, rtol=RTOL, atol=ATOL)
     self.assertAlmostEquals(pval, 0.009)
예제 #3
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     lm = moran.Moran_Local_Rate.by_col(df, ['SID79'], ['BIR79'], w=self.w,
                                        outvals=['p_z_sim', 'z_sim'],
                                        transformation='r', permutations=99)
     self.assertAlmostEquals(lm['SID79-BIR79_z_sim'][0],  -0.13699844503985936, 7)
     self.assertAlmostEquals(lm['SID79-BIR79_p_z_sim'][0], 0.44551601210081715)
예제 #4
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     mi = moran.Moran_Rate.by_col(df, ['SID79'], ['BIR79'], w=self.w, two_tailed=False)
     sidr = np.unique(mi["SID79-BIR79_moran_rate"].values)
     pval = np.unique(mi["SID79-BIR79_p_sim"].values)
     np.testing.assert_allclose(sidr, 0.16622343552567395, rtol=RTOL, atol=ATOL)
     self.assertAlmostEqual(pval, 0.009)
예제 #5
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     w = pysal.open(pysal.examples.get_path("sids2.gal")).read()
     mi = moran.Moran.by_col(df, ['SIDR74'], w=w, two_tailed=False)
     sidr = np.unique(mi.SIDR74_moran.values)
     pval = np.unique(mi.SIDR74_p_sim.values)
     np.testing.assert_allclose(sidr, 0.24772519320480135, atol=ATOL, rtol=RTOL)
     self.assertAlmostEquals(pval, 0.001)
예제 #6
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     w = pysal.open(pysal.examples.get_path("sids2.gal")).read()
     mi = moran.Moran.by_col(df, ['SIDR74'], w=w, two_tailed=False)
     sidr = np.unique(mi.SIDR74_moran.values)
     pval = np.unique(mi.SIDR74_p_sim.values)
     np.testing.assert_allclose(sidr, 0.24772519320480135, atol=ATOL, rtol=RTOL)
     self.assertAlmostEqual(pval, 0.001)
예제 #7
0
 def setUp(self):
     import pandas as pd
     self.columbus = pdio.read_files(get_path('columbus.shp'))
     grid = [Polygon([(0,0),(0,1),(1,1),(1,0)]), 
             Polygon([(0,1),(0,2),(1,2),(1,1)]), 
             Polygon([(1,2),(2,2),(2,1),(1,1)]), 
             Polygon([(1,1),(2,1),(2,0),(1,0)])]
     regime = [0,0,1,1]
     ids = range(4)
     data = np.array((regime, ids)).T
     self.exdf = pd.DataFrame(data, columns=['regime', 'ids'])
     self.exdf['geometry'] = grid
예제 #8
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     np.random.seed(12345)
     moran.Moran_Local_BV.by_col(df, ['SIDR74', 'SIDR79'], w=self.w,
                                 inplace=True, outvals=['z_sim', 'p_z_sim'],
                                 transformation='r', permutations=99)
     bvstats = df['SIDR79-SIDR74_moran_local_bv'].values
     bvz = df['SIDR79-SIDR74_z_sim'].values
     bvzp = df['SIDR79-SIDR74_p_z_sim'].values
     self.assertAlmostEquals(bvstats[0], 1.4649221250620736)
     self.assertAlmostEquals(bvz[0],  1.657427, 5)
     self.assertAlmostEquals(bvzp[0], 0.048717, 5)
예제 #9
0
 def test_by_col(self):
     import pysal.contrib.pdio as pdio
     df = pdio.read_files(pysal.examples.get_path('sids2.dbf'))
     np.random.seed(12345)
     moran.Moran_Local_BV.by_col(df, ['SIDR74', 'SIDR79'], w=self.w,
                                 inplace=True, outvals=['z_sim', 'p_z_sim'],
                                 transformation='r', permutations=99)
     bvstats = df['SIDR79-SIDR74_moran_local_bv'].values
     bvz = df['SIDR79-SIDR74_z_sim'].values
     bvzp = df['SIDR79-SIDR74_p_z_sim'].values
     self.assertAlmostEqual(bvstats[0], 1.4649221250620736)
     self.assertAlmostEqual(bvz[0],  1.657427, 5)
     self.assertAlmostEqual(bvzp[0], 0.048717, 5)
예제 #10
0
파일: test_plot.py 프로젝트: ljwolf/pysal
def test_mplot():
    link = ps.examples.get_path('columbus.shp')

    db = read_files(link)
    y = db['HOVAL'].values
    w = ps.queen_from_shapefile(link)
    w.transform = 'R'

    m = ps.Moran(y, w)

    fig = mplot(m, xlabel='Response', ylabel='Spatial Lag',
                title='Moran Scatterplot', custom=(7,7))
    plt.close(fig)
예제 #11
0
 def setUp(self):
     import pandas as pd
     self.columbus = pdio.read_files(get_path('columbus.shp'))
     grid = [
         Polygon([(0, 0), (0, 1), (1, 1), (1, 0)]),
         Polygon([(0, 1), (0, 2), (1, 2), (1, 1)]),
         Polygon([(1, 2), (2, 2), (2, 1), (1, 1)]),
         Polygon([(1, 1), (2, 1), (2, 0), (1, 0)])
     ]
     regime = [0, 0, 1, 1]
     ids = range(4)
     data = np.array((regime, ids)).T
     self.exdf = pd.DataFrame(data, columns=['regime', 'ids'])
     self.exdf['geometry'] = grid
예제 #12
0
def test_mplot():
    link = ps.examples.get_path('columbus.shp')

    db = read_files(link)
    y = db['HOVAL'].values
    w = ps.queen_from_shapefile(link)
    w.transform = 'R'

    m = ps.Moran(y, w)

    fig = mplot(m,
                xlabel='Response',
                ylabel='Spatial Lag',
                title='Moran Scatterplot',
                custom=(7, 7))
    plt.close(fig)