esda.MoranLocalPartial¶
- class esda.MoranLocalPartial(permutations=999, unit_scale=True, partial_labels=True, alternative='two-sided')[source]¶
- __init__(permutations=999, unit_scale=True, partial_labels=True, alternative='two-sided')[source]¶
Compute the Multivariable Local Moran statistics under partial dependence [Wol24]
- Parameters:
- permutations
int 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.
- alternative
str(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
- ———-
- connectivity
W The weights matrix inputted, but row standardized
- D
array The “design” matrix used in computation. If X is not None, this will be [1 y X]
- R
array The “response” matrix used in computation. Will always be the same shape as D and contain [1, Wy, Wy, ….]
- DtDi
array empirical parameter covariance matrix the P x P matrix describing the variance and covariance of y and X.
- P
int the number of parameters. 1 if X is not provided.
- ``association_``
array 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_``
array 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_``
array 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_``
array 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_``
array the (N,) array of quadrant classifications for the part-regressive relationships. See the partial_labels argument for more information.
- permutations
Methods
__init__([permutations, unit_scale, ...])Compute the Multivariable Local Moran statistics under partial dependence [Wol24]
fit(X, y, W)Fit the partial local Moran statistic on input data
Attributes
The association between y and the local average of y, removing the correlation due to x and the local average of y
The classifications (in terms of cluster-type and outlier-type) for the
association_statistics.The components of the local statistic.
Simulated distribution of
association_, assuming that there isThe pseudo-p-value built using map randomization for the structural relationship between y and its local average, removing the correlation due to the relationship between x and the local average of y.
- property association_¶
The association between y and the local average of y, removing the correlation due to x and the local average of y
- fit(X, y, W)[source]¶
Fit the partial local Moran statistic on input data
- Parameters:
- X(N,p)
array array of data that is used as confounding factors to account for their covariance with Y.
- y(N,1)
array array of data that is the targeted outcome covariate to compute the multivariable Moran’s I
- W(N,N)
weightsobject spatial weights instance as W or Graph aligned with y. Immediately row-standardized.
- X(N,p)
- Returns:
- self
object this MoranLocalPartial() statistic after fitting to data
- self
- property labels_¶
The classifications (in terms of cluster-type and outlier-type) for the
association_statistics. If the quads requested are mvquads, then the classification is done with respect to the left and right components (first and second columns ofpartials_).If the quads requested are uvquads, then this will only be computed with respect to the outcome and the local average.
The cluster typology is:
1: above-average left and right components
2: below-average left, above-average right component
3: below-average left and right components
4: above-average left, below-average right component
- property partials_¶
The components of the local statistic. The first column is the structural exogenous component of the data, and the second is the local average of y.
- property reference_distribution_¶
- Simulated distribution of
association_, assuming that there is no structural relationship between y and its local average;
the same observed structural relationship between y and x.
- Simulated distribution of
- property significance_¶
The pseudo-p-value built using map randomization for the structural relationship between y and its local average, removing the correlation due to the relationship between x and the local average of y.