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

Bivariate Moran Matrix

Calculates bivariate Moran between all pairs of a set of variables.

variables : array or pandas.DataFrame

sequence of variables to be assessed

w : W

a spatial weights object

permutations : int

number of permutations

varnames : list, optional if variables is an array

Strings for variable names. Will add an attribute to Moran_BV objects in results needed for plotting in splot or .plot(). Default =None. Note: If variables is a pandas.DataFrame varnames will automatically be generated

results : dictionary

(i, j) is the key for the pair of variables, values are the Moran_BV objects.


open dbf

>>> import pysal.lib
>>> f ="sids2.dbf"))

pull of selected variables from dbf and create numpy arrays for each

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

create a contiguity matrix from an external gal file

>>> w ="")).read()

create an instance of Moran_BV_matrix

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

check values

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