Skip to content

pygeostats.spatial_autocorrelation

Spatial autocorrelation methods.

global_getis_ord_g

global_getis_ord_g(values: ndarray, weights: ndarray, permutations: int = 0, random_state: Optional[int] = None) -> Dict[str, float]

Compute global Getis-Ord General G statistic.

This implementation returns the observed G and an optional permutation p-value around the permutation null distribution.

local_getis_ord_g

local_getis_ord_g(values: ndarray, weights: ndarray, include_self: bool = True) -> Dict[str, np.ndarray]

Compute local Getis-Ord G_i* z-scores.

Parameters:

Name Type Description Default
values (ndarray, shape(n))

Observed attribute values.

required
weights (ndarray, shape(n, n))

Spatial weights matrix.

required
include_self bool

Whether to include self-weight in each local neighborhood.

True

gearys_c

gearys_c(values: ndarray, weights: ndarray, permutations: int = 0, random_state: Optional[int] = None) -> Dict[str, float]

Compute global Geary's C with optional permutation p-value.

local_gearys_c

local_gearys_c(values: ndarray, weights: ndarray) -> Dict[str, np.ndarray]

Compute local Geary components for each observation.

local_morans_i

local_morans_i(values: ndarray, weights: ndarray) -> Dict[str, np.ndarray]

Compute local Moran's I for each observation.

morans_i

morans_i(values: ndarray, weights: ndarray, permutations: int = 0, random_state: Optional[int] = None) -> Dict[str, float]

Compute global Moran's I with optional permutation p-value.

row_standardize_weights

row_standardize_weights(weights: ndarray) -> np.ndarray

Row-standardize a square weights matrix.

spatial_weights_distance_band

spatial_weights_distance_band(coords: ndarray, threshold: float, binary: bool = True, row_standardize: bool = True) -> np.ndarray

Build a distance-band spatial weights matrix.

If binary is False, uses inverse distance weights inside the threshold.

spatial_weights_inverse_distance

spatial_weights_inverse_distance(coords: ndarray, power: float = 1.0, max_distance: Optional[float] = None, row_standardize: bool = True) -> np.ndarray

Build an inverse-distance spatial weights matrix.

spatial_weights_knn

spatial_weights_knn(coords: ndarray, k: int = 8, row_standardize: bool = True) -> np.ndarray

Build a binary k-nearest-neighbor spatial weights matrix.