pysal.explore.esda.
Moran_BV_matrix
(variables, w, permutations=0, varnames=None)[源代码]¶二元Moran矩阵
计算一组变量的所有对之间的二变量Moran。
参数: |
|
---|
实例
打开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