# pysal.explore.esda.Moran_Local¶

class pysal.explore.esda.Moran_Local(y, w, transformation='r', permutations=999, geoda_quads=False)[source]

Local Moran Statistics

Parameters: y : array (n,1), attribute array 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 geoda_quads : boolean (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

Notes

For technical details see [Ans95].

Examples

>>> import pysal.lib
>>> import numpy as np
>>> np.random.seed(10)
>>> f = pysal.lib.io.open(pysal.lib.examples.get_path("desmith.txt"))
>>> y = np.array(f.by_col['z'])
>>> from pysal.explore.esda.moran import Moran_Local
>>> lm = Moran_Local(y, w, transformation = "r", permutations = 99)
>>> lm.q
array([4, 4, 4, 2, 3, 3, 1, 4, 3, 3])
>>> lm.p_z_sim[0]
0.24669152541631179
>>> lm = Moran_Local(y, w, transformation = "r", permutations = 99,                             geoda_quads=True)
>>> lm.q
array([4, 4, 4, 3, 2, 2, 1, 4, 2, 2])


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: y : array original variable w : W original w object permutations : int number of random permutations for calculation of pseudo p_values Is : array local Moran’s I values q : array (if permutations>0) values indicate quandrant location 1 HH, 2 LH, 3 LL, 4 HL sim : array (permutations by n) (if permutations>0) I values for permuted samples p_sim : array (if permutations>0) p-values 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_sim : array (if permutations>0) average values of local Is from permutations VI_sim : array (if permutations>0) variance of Is from permutations seI_sim : array (if permutations>0) standard deviations of Is under permutations. z_sim : arrray (if permutations>0) standardized Is based on permutations p_z_sim : array (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

Methods

 by_col(df, cols[, w, inplace, pvalue, outvals]) Function to compute a Moran_Local statistic on a dataframe
 calc
__init__(y, w, transformation='r', permutations=999, geoda_quads=False)[source]

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

Methods

 __init__(y, w[, transformation, …]) Initialize self. by_col(df, cols[, w, inplace, pvalue, outvals]) Function to compute a Moran_Local statistic on a dataframe calc(w, z)