esda.Moran_Local_BV¶
- class esda.Moran_Local_BV(x, y, w, transformation='r', permutations=999, geoda_quads=False, n_jobs=1, keep_simulations=True, seed=None, island_weight=0)[source]¶
Bivariate Local Moran Statistics.
- Parameters:
- w
W
|Graph
spatial weights instance as W or Graph 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.
p_values
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
- keep_simulations
Boolean
(default=True) If True, the entire matrix of replications under the null is stored in memory and accessible; otherwise, replications are not saved
- seedNone/int
Seed to ensure reproducibility of conditional randomizations. Must be set here, and not outside of the function, since numba does not correctly interpret external seeds nor numpy.random.RandomState instances.
- island_weight:
value to use as a weight for the “fake” neighbor for every island. If numpy.nan, will propagate to the final local statistic depending on the stat_func. If 0, then the lag is always zero for islands.
W
| Graph
original w object
(if permutations>0) standard deviations of Is under permutations.
arrray
(if permutations>0) standardized Is based on permutations
(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
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.
- __init__(x, y, w, transformation='r', permutations=999, geoda_quads=False, n_jobs=1, keep_simulations=True, seed=None, island_weight=0)[source]¶
Methods
|
|
|
Function to compute a Moran_Local_BV statistic on a dataframe |
- classmethod by_col(df, x, y=None, w=None, inplace=False, pvalue='sim', outvals=None, **stat_kws)[source]¶
Function to compute a Moran_Local_BV statistic on a dataframe
- Parameters:
the bivariate statistic. if no Y is provided, pariwise comparisons
among the X variates are used instead.
- w
W
|Graph
spatial weights instance as W or Graph aligned with the dataframe. If not provided, this is searched for in the dataframe’s metadata
return a series contaning the results of the computation. If
operating inplace, the derived columns will be named
‘column_moran_local_bv’
the Moran_Local_BV statistic’s documentation for available p-values
Moran_Local_BV statistic
documentation for the Moran_Local_BV statistic.
the
relevant
columns
attached.