pysal.explore.esda.Moran_Local_Rate

class pysal.explore.esda.Moran_Local_Rate(e, b, w, adjusted=True, transformation='r', permutations=999, geoda_quads=False)[source]

Adjusted Local Moran Statistics for Rate Variables [Assuncao1999]

Parameters:
e : array

(n,1), an event variable across n spatial units

b : array

(n,1), a population-at-risk variable across n spatial units

w : W

weight instance assumed to be aligned with y

adjusted : boolean

whether or not local Moran statistics need to be adjusted for rate variable

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

Attributes
———-
y : array

rate variables computed from parameters e and b if adjusted is True, y is standardized rates otherwise, y is raw rates

w : W

original w object

permutations : int

number of random permutations for calculation of pseudo p_values

I : float

value of Moran’s I

q : array

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

sim : array

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

p_sim : array

(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 Iis. It is either extremely high or extremely low in the distribution of simulated Is

EI_sim : float

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

VI_sim : float

(if permutations>0) variance of I from permutations

seI_sim : float

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

z_sim : float

(if permutations>0) standardized I based on permutations

p_z_sim : float

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

Examples

>>> import pysal.lib
>>> import numpy as np
>>> np.random.seed(10)
>>> w = pysal.lib.io.open(pysal.lib.examples.get_path("sids2.gal")).read()
>>> f = pysal.lib.io.open(pysal.lib.examples.get_path("sids2.dbf"))
>>> e = np.array(f.by_col('SID79'))
>>> b = np.array(f.by_col('BIR79'))
>>> from pysal.explore.esda.moran import Moran_Local_Rate
>>> lm = Moran_Local_Rate(e, b, w, transformation = "r", permutations = 99)
>>> lm.q[:10]
array([2, 4, 3, 1, 2, 1, 1, 4, 2, 4])
>>> lm = Moran_Local_Rate(e, b, w,  transformation = "r",  permutations = 99,  geoda_quads=True)
>>> lm.q[:10]
array([3, 4, 2, 1, 3, 1, 1, 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

Methods

by_col(df, events, populations[, w, …]) Function to compute a Moran_Local_Rate statistic on a dataframe
calc  
__init__(e, b, w, adjusted=True, transformation='r', permutations=999, geoda_quads=False)[source]

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

Methods

__init__(e, b, w[, adjusted, …]) Initialize self.
by_col(df, events, populations[, w, …]) Function to compute a Moran_Local_Rate statistic on a dataframe
calc(w, z)