esda.Moran_BV_matrix¶
- 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.
- Parameters:
- w
W
a spatial weights object
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
- Returns
- ——-
- results
dictionary
(i, j) is the key for the pair of variables, values are the Moran_BV objects.
Examples
open dbf
>>> import libpysal
>>> f = libpysal.io.open(libpysal.examples.get_path("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 = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
create an instance of Moran_BV_matrix
>>> from esda.moran import Moran_BV_matrix
>>> res = Moran_BV_matrix(vars, w, varnames = varnames)
check values
>>> round(res[(0, 1)].I,7)
0.1936261
>>> round(res[(3, 0)].I,7)
0.3770138