spacenet.pcf.helpers.spatial_bootstrap#

spacenet.pcf.helpers.spatial_bootstrap(spatial_network, edge_weight_name, object_indices_A, contributions, weight_matrix=None)#

Compute the 95% confidence interval for the pair correlation function at each radius (and target marker, if applicable) using method of spatial bootstrap on spatial networks.

Parameters:
spatial_networknetworkx.Graph

The spatial network on which to compute the confidence intervals. Edges should have a weight attribute corresponding to the distance between nodes.

edge_weight_namestr

The name of the edge attribute in the network that corresponds to the distance between nodes. Default is ‘Distance’.

object_indices_Aarray-like

The indices of the nodes in population A for which to compute confidence intervals. This should correspond to the first dimension of the contributions array.

contributionsnumpy.ndarray

An array of contributions to the pair correlation function for each node in object_indices_A. This should be the output of the compute_contributions_parallel function, and can be either 2D (n_objects_A, number_of_radii) or 3D (n_objects_A, number_of_target_markers, number_of_radii) depending on whether weights are used.

weight_matrixnumpy.ndarray, optional

An optional weight matrix to apply to the contributions when computing confidence intervals, required for computing confidence intervals for cross weighted pair correlation functions. This should be of shape (n_objects_A, number_of_target_markers_A). If None, no weights will be applied. Default is None.

Returns:
confidence_intervalnumpy.ndarray

An array of confidence intervals for the pair correlation function at each radius (and target marker, if applicable). The shape of this array will depend on the shape of the contributions array and whether weights are used.

  • For 2D contributions, the output will be of shape (2,number_of_radii) where the first dimension corresponds to the lower and upper bounds of the confidence interval.

  • For 3D contributions with weights, the output will be of shape (2, number_of_target_markers, number_of_radii) where the first dimension corresponds to the lower and upper bounds of the confidence interval for each target marker and radius.

  • For 4D contributions (cross-weighted case), the output will be of shape (2, number_of_target_markers_A, number_of_target_markers_B, number_of_radii) where the first dimension corresponds to the lower and upper bounds of the confidence interval for each combination of target markers and radius.

Notes

This function extends Loh’s method of spatial bootstrap for estimating confidence intervals of the pair correlation function for spatial networks. For details, see the reference paper: