esda.Moran_Local_BV

class esda.Moran_Local_BV(x, y, w, transformation='r', permutations=999, geoda_quads=False)[source]

Bivariate Local Moran Statistics

Parameters
xarray

x-axis variable

yarray

(n,1), wy will be on y axis

wW

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.

permutationsint

number of random permutations for calculation of pseudo p_values

geoda_quadsbool

(default=False) If True use GeoDa scheme: HH=1, LL=2, LH=3, HL=4 If False use PySAL Scheme: HH=1, LH=2, LL=3, HL=4

Examples

>>> import libpysal
>>> import numpy as np
>>> np.random.seed(10)
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> x = np.array(f.by_col['SIDR79'])
>>> y = np.array(f.by_col['SIDR74'])
>>> from esda.moran import Moran_Local_BV
>>> lm =Moran_Local_BV(x, y, w, transformation = "r",                                permutations = 99)
>>> lm.q[:10]
array([3, 4, 3, 4, 2, 1, 4, 4, 2, 4])
>>> lm = Moran_Local_BV(x, y, w, transformation = "r",                                permutations = 99, geoda_quads=True)
>>> lm.q[:10]
array([2, 4, 2, 4, 3, 1, 4, 4, 3, 4])

Note random components result is slightly different values across architectures so the results have been removed from doctests and will be moved into unittests that are conditional on architectures

Attributes
zxarray

original x variable standardized by mean and std

zyarray

original y variable standardized by mean and std

wW

original w object

permutationsint

number of random permutations for calculation of pseudo p_values

Isfloat

value of Moran’s I

qarray

(if permutations>0) values indicate quandrant location 1 HH, 2 LH, 3 LL, 4 HL

simarray

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

p_simarray

(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed Ii is further away or extreme from the median of simulated values. It is either extremelyi high or extremely low in the distribution of simulated Is.

EI_simarray

(if permutations>0) average values of local Is from permutations

VI_simarray

(if permutations>0) variance of Is from permutations

seI_simarray

(if permutations>0) standard deviations of Is under permutations.

z_simarrray

(if permutations>0) standardized Is based on permutations

p_z_simarray

(if permutations>0) p-values based on standard normal approximation from permutations (one-sided) for two-sided tests, these values should be multiplied by 2

__init__(self, x, y, w, transformation='r', permutations=999, geoda_quads=False)[source]

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

Methods

__init__(self, x, y, w[, transformation, …])

Initialize self.

by_col(df, x[, y, w, inplace, pvalue, outvals])

Function to compute a Moran_Local_BV statistic on a dataframe

calc(self, w, zx, zy)