esda.Moran_BV¶
- class esda.Moran_BV(x, y, w, transformation='r', permutations=999)[source]¶
Bivariate Moran’s I
- Parameters:
- w
W|Graph spatial weights instance as W or Graph aligned with x and y
- transformation{‘R’, ‘B’, ‘D’, ‘U’, ‘V’}
weights transformation, default is row-standardized “r”. Other options include “B”: binary, “D”: doubly-standardized, “O”: restore original transformation (applicable only if
wis passed asW), “V”: variance-stabilizing.
p_values
W | Graphoriginal w object
Notes
Inference is only based on permutations as analytical results are not too reliable.
Examples
>>> import libpysal
>>> import numpy as np
Set random number generator seed so we can replicate the example
>>> np.random.seed(10)
Open the sudden infant death dbf file and read in rates for 74 and 79 converting each to a numpy array
>>> f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
>>> SIDR74 = np.array(f.by_col['SIDR74'])
>>> SIDR79 = np.array(f.by_col['SIDR79'])
Read a GAL file and construct our spatial weights object
>>> w = libpysal.io.open(libpysal.examples.get_path("sids2.gal")).read()
Create an instance of Moran_BV
>>> from esda.moran import Moran_BV
>>> mbi = Moran_BV(SIDR79, SIDR74, w)
What is the bivariate Moran’s I value
>>> round(mbi.I, 3)
0.156
Based on 999 permutations, what is the p-value of our statistic
>>> round(mbi.p_z_sim, 3)
0.001
Methods
|
|
|
Function to compute a Moran_BV statistic on a dataframe |
|
Plot a Moran scatterplot with optional coloring for significant points. |
|
Global Moran's I simulated reference distribution. |
- classmethod by_col(df, x, y=None, w=None, inplace=False, pvalue='sim', outvals=None, **stat_kws)[source]¶
Function to compute a Moran_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’
the Moran_BV statistic’s documentation for available p-values
Moran_BV statistic
documentation for the Moran_BV statistic.
therelevantcolumnsattached.
- plot_scatter(ax=None, scatter_kwds=None, fitline_kwds=None)[source]¶
Plot a Moran scatterplot with optional coloring for significant points.
- Parameters:
- ax
matplotlib.axes.Axes, optional Pre-existing axes for the plot, by default None.
- ax
matplotlib.axes.AxesAxes object with the Moran scatterplot.
- plot_simulation(ax=None, legend=False, fitline_kwds=None, **kwargs)[source]¶
Global Moran’s I simulated reference distribution.
- Parameters:
- ax
matplotlib.axes.Axes, optional Pre-existing axes for the plot, by default None.
- ax
by default None.
matplotlib.axes.AxesAxes object with the Moran scatterplot.
Notes
This requires optional dependencies matplotlib and seaborn.