pysal.explore.esda.Moran_BV_matrix

pysal.explore.esda.Moran_BV_matrix(variables, w, permutations=0, varnames=None)[源代码]

二元Moran矩阵

计算一组变量的所有对之间的二变量Moran。

参数:
variables : array或pandas.dataframe

待评估变量序列

w : W

空间权重对象

permutations : 利息

排列数

varnames : 列表,如果变量是数组,则为可选

变量名的字符串。将向添加属性 Moran_BV 打印所需结果中的对象 splot 或`.plot()`。默认值=无。注:如果变量是 pandas.DataFrame 将自动生成变量名

返回
-
results : 词典

(i,j)是变量对的关键,值是moran_bv对象。

实例

打开DBF

>>> import pysal.lib
>>> f = pysal.lib.io.open(pysal.lib.examples.get_path("sids2.dbf"))

从dbf中提取所选变量并为每个变量创建numpy数组

>>> varnames = ['SIDR74',  'SIDR79',  'NWR74',  'NWR79']
>>> vars = [np.array(f.by_col[var]) for var in varnames]

从外部gal文件创建连续矩阵

>>> w = pysal.lib.io.open(pysal.lib.examples.get_path("sids2.gal")).read()

创建Moran_bv_矩阵的实例

>>> from pysal.explore.esda.moran import Moran_BV_matrix
>>> res = Moran_BV_matrix(vars,  w,  varnames = varnames)

校验值

>>> round(res[(0,  1)].I,7)
0.1936261
>>> round(res[(3,  0)].I,7)
0.3770138