esda.Moran_Rate¶
- class esda.Moran_Rate(e, b, w, adjusted=True, transformation='r', permutations=999, two_tailed=True)[source]¶
Adjusted Moran’s I Global Autocorrelation Statistic for Rate Variables []
- Parameters:
- e
array
an event variable measured across n spatial units
- b
array
a population-at-risk variable measured across n spatial units
- w
W
spatial weights instance
- adjustedbool
whether or not Moran’s I needs 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.
- two_tailedbool
If True (default), analytical p-values for Moran’s I are two-tailed, otherwise they are one tailed.
- permutations
python:int
number of random permutations for calculation of pseudo p_values
- e
Examples
>>> import libpysal >>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read() >>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf")) >>> e = np.array(f.by_col('SID79')) >>> b = np.array(f.by_col('BIR79')) >>> from esda.moran import Moran_Rate >>> mi = Moran_Rate(e, b, w, two_tailed=False) >>> "%6.4f" % mi.I '0.1662' >>> "%6.4f" % mi.p_norm '0.0042'
- Attributes:
- y
array
rate variable 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
python:int
number of permutations
- I
python:float
value of Moran’s I
- EI
python:float
expected value under normality assumption
- VI_norm
python:float
variance of I under normality assumption
- seI_norm
python:float
standard deviation of I under normality assumption
- z_norm
python:float
z-value of I under normality assumption
- p_norm
python:float
p-value of I under normality assumption
- VI_rand
python:float
variance of I under randomization assumption
- seI_rand
python:float
standard deviation of I under randomization assumption
- z_rand
python:float
z-value of I under randomization assumption
- p_rand
python:float
p-value of I under randomization assumption
- two_tailedbool
If True, p_norm and p_rand are two-tailed p-values, otherwise they are one-tailed.
- 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 I is extreme if it is either extremely greater or extremely lower than the values obtained from permutaitons
- EI_sim
python:float
(if permutations>0) average value of I from permutations
- VI_sim
python:float
(if permutations>0) variance of I from permutations
- seI_sim
python:float
(if permutations>0) standard deviation of I under permutations.
- z_sim
python:float
(if permutations>0) standardized I based on permutations
- p_z_sim
python:float
(if permutations>0) p-value based on standard normal approximation from
- y
Methods
__init__
(e, b, w[, adjusted, ...])by_col
(df, events, populations[, w, ...])Function to compute a Moran_Rate statistic on a dataframe