pysal.explore.esda.Moran_BV

class pysal.explore.esda.Moran_BV(x, y, w, transformation='r', permutations=999)[source]

Bivariate Moran’s I

Parameters:
x : array

x-axis variable

y : array

wy will be on y axis

w : W

weight instance assumed to be aligned with y

transformation : {‘R’, ‘B’, ‘D’, ‘U’, ‘V’}

weights transformation, default is row-standardized “r”. Other options include “B”: binary, “D”: doubly-standardized, “U”: untransformed (general weights), “V”: variance-stabilizing.

permutations : int

number of random permutations for calculation of pseudo p_values

Notes

Inference is only based on permutations as analytical results are not too reliable.

Examples

>>> import pysal.lib
>>> import numpy as np

Set random number generator seed so we can replicate the example

>>> np.random.seed(10)

Open the sudden infant death dbf file and read in rates for 74 and 79 converting each to a numpy array

>>> f = pysal.lib.io.open(pysal.lib.examples.get_path("sids2.dbf"))
>>> SIDR74 = np.array(f.by_col['SIDR74'])
>>> SIDR79 = np.array(f.by_col['SIDR79'])

Read a GAL file and construct our spatial weights object

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

Create an instance of Moran_BV >>> from pysal.explore.esda.moran import Moran_BV >>> mbi = Moran_BV(SIDR79, SIDR74, w)

What is the bivariate Moran’s I value

>>> round(mbi.I, 3)
0.156

Based on 999 permutations, what is the p-value of our statistic

>>> round(mbi.p_z_sim, 3)
0.001
Attributes:
zx : array

original x variable standardized by mean and std

zy : array

original y variable standardized by mean and std

w : W

original w object

permutation : int

number of permutations

I : float

value of bivariate Moran’s I

sim : array

(if permutations>0) vector of I values for permuted samples

p_sim : float

(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed I is extreme it is either extremely high or extremely low

EI_sim : array

(if permutations>0) average value of I from permutations

VI_sim : array

(if permutations>0) variance of I from permutations

seI_sim : array

(if permutations>0) standard deviation of I under permutations.

z_sim : array

(if permutations>0) standardized I based on permutations

p_z_sim : float

(if permutations>0) p-value based on standard normal approximation from permutations

Methods

by_col(df, x[, y, w, inplace, pvalue, outvals]) Function to compute a Moran_BV statistic on a dataframe
__init__(x, y, w, transformation='r', permutations=999)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(x, y, w[, transformation, permutations]) Initialize self.
by_col(df, x[, y, w, inplace, pvalue, outvals]) Function to compute a Moran_BV statistic on a dataframe