esda.MoranLocalConditional

class esda.MoranLocalConditional(permutations=999, unit_scale=True, transformer=None, alternative='two-sided')[source]

Fit a local moran statistic for y after regressing out the effects of confounding X on y. A “stronger” version of the MoranLocalPartial statistic, as defined by [Wol24]

__init__(permutations=999, unit_scale=True, transformer=None, alternative='two-sided')[source]

Compute the Multivariable Local Moran statistics under partial dependence [Wol24]

Parameters

permutationsint

the number of permutations to run for the inference, driven by conditional randomization.

unit_scalebool

whether to enforce unit variance in the local statistics. This normalizes the variance of the data at inupt, ensuring that the covariance statistics are not overwhelmed by any single covariate’s large variance.

partial_labelsbool, default=True

whether to calculate the classification based on the part-regressive quadrant classification or the univariate quadrant classification, like a classical Moran’s I. When mvquads is True, the variables are labelled as: - label 1: observations with large y - rho * x that also have large Wy values. - label 2: observations with small y - rho * x values that also have large Wy values. - label 3: observations with small y - rho * x values that also have small Wy values. - label 4: observations with large y - rho * x values that have small Wy values.

alternativestr (default: ‘two-sided’)

the alternative hypothesis for the inference. One of ‘two-sided’, ‘greater’, ‘lesser’, ‘directed’, or ‘folded’. See the esda.significance.calculate_significance() documentation for more information.

Attributes:
connectivityThe weights matrix inputted, but row standardized
DThe “design” matrix used in computation. If X is

not None, this will be [1 y X]

Rthe “response” matrix used in computation. Will

always be the same shape as D and contain [1, Wy, Wy, ….]

DtDiempirical parameter covariance matrix

the P x P matrix describing the variance and covariance of y and X.

Pthe number of parameters. 1 if X is not provided.
association_the N,P matrix of multivariable LISA statistics.

the first column, lmos[:,1] is the LISAs corresponding to the relationship between Wy and y conditioning on X.

reference_distribution_the (N, permutations, P+1) realizations from the conditional

randomization to generate reference distributions for each Local Moran statistic. rlmos_[:,:,1] pertain to the reference distribution of y and Wy.

significance_the (N, P) matrix of quadrant classifications for the

part-regressive relationships. quads[:,0] pertains to the relationship between y and Wy. The mean is not classified, since it’s just binary above/below mean usually.

partials_: the (N,2,P+1) matrix of part-regressive contributions.

The ith slice of partials_[:,:,i] contains the partial regressive contribution of that covariate, with the first column indicating the part-regressive outcome and the second indicating the part-regressive design. The partial regression matrix starts at zero, so partials_[:,:,0] corresponds to the partial regression describing the relationship between y and Wy.

labels_the (N,) array of quadrant classifications for the

part-regressive relationships. See the partial_labels argument for more information.

Methods

__init__([permutations, unit_scale, ...])

Compute the Multivariable Local Moran statistics under partial dependence [Wol24]

by_col(df, cols[, w, inplace, pvalue, outvals])

Function to compute a Moran_Local statistic on a dataframe.

explore(gdf[, crit_value])

Create interactive map of LISA indicators

fit(X, y, W)

Parameters :2: (WARNING/2) Title underline too short. Parameters --------- y (N,1) array array of data that is the targeted "outcome" covariate to compute the multivariable Moran's I X (N,3) array array of data that is used as "confounding factors" to account for their covariance with Y. W (N,N) weights object spatial weights instance as W or Graph aligned with y. Immediately row-standardized.

get_cluster_labels([crit_value])

Return LISA cluster labels for each observation.

plot(gdf[, crit_value])

Create static map of LISA indicators

plot_combination(gdf, attribute[, ...])

Produce three-plot visualisation of Moran Scatteprlot, LISA cluster and Choropleth maps, with Local Moran region and quadrant masking

plot_scatter([crit_value, ax, scatter_kwds, ...])

Plot a Moran scatterplot with optional coloring for significant points.

fit(X, y, W)[source]

Parameters

y(N,1) array

array of data that is the targeted “outcome” covariate to compute the multivariable Moran’s I

X(N,3) array

array of data that is used as “confounding factors” to account for their covariance with Y.

W(N,N) weights object

spatial weights instance as W or Graph aligned with y. Immediately row-standardized.

Returns:
A fitted MoranLocalConditional() estimator