geovalidate.correlogram_range

geovalidate.correlogram_range(X, y, n_bins=15, max_distance=None, n_sample=1000, random_state=None)[source]

Estimate the distance at which spatial autocorrelation drops to zero.

Builds an empirical spatial correlogram – the average normalised cross-product (y_i - y_bar)(y_j - y_bar) / σ**2 for all pairs at each distance lag – and returns the lag at which it first crosses zero, found by linear interpolation between adjacent bin centres.

Works for 2-D spatial data and 1-D time-series (pass a 1-D array of time indices; distance is then the absolute lag).

Parameters:
X : GeoDataFrame | GeoSeries | (n, 2) ndarray | (n,) ndarray

Locations or time indices.

y : array-like of shape (n,)

Observed values.

n_bins : int, default 15

Number of distance bins for the correlogram.

max_distance : float or None

Upper limit of the correlogram. Defaults to half the maximum pairwise distance.

n_sample : int or None

Subsample to this many points before computing all pairwise distances (O(n**2)). None uses all points.

random_state : int, RandomState, or None

Returns:

Estimated range. Returns max_distance if the correlogram does not cross zero within the window.

Return type:

float

Examples

>>> d = correlogram_range(gdf, y)
>>> lb = LocalBootstrap(bandwidth=d)
>>> lp = LocalPermutation(threshold=d)