netneurotools.spatial.local_lees_i

netneurotools.spatial.local_lees_i(annot_1, annot_2, weight)[source]

Calculate local Lee’s I for spatial autocorrelation.

Parameters:
  • annot_1 (array-like, shape (n,)) – Array of annotations to calculate Lee’s I for.

  • annot_2 (array-like, shape (n,)) – Array of annotations to calculate Lee’s I for.

  • weight (array-like, shape (n, n)) – Spatial weight matrix. Note that we do not explicitly check for symmetry in the weight matrix, nor zero-diagonal elements.

Returns:

local_lees_i – Local Lee’s I values for the given annotations and weight matrix.

Return type:

array, shape (n,)

Notes

Local Lee’s I is calculated as:

\[L_i(x,y) = \frac{(\sum_{j=1}^n w_{ij}(x_i - \bar{x})) (\sum_{j=1}^n w_{ij}(y_i - \bar{y}))} {\sqrt{\sum_{i=1}^n(x_i - \bar{x})^2}\sqrt{\sum_{i=1}^n(y_i - \bar{y})^2}}\]

where \(n\) is the number of observations, \(w_{ij}\) is the spatial weight between observations \(i\) and \(j\), \(x_i\) is the annotation for observation \(i\), and \(\bar{x}\) is the mean annotation value. \(x\) and \(y\) are the annotations for the two variables.

The value can be tested using the R pacakge spdep:

x <- rnorm(100)
y <- rnorm(100)
m <- matrix(runif(100*100), nrow=100)
lee(x, y, mat2listw(m), 100)