morans_i#
- morans_i(domain, population, label_name, include_boundaries=None, exclude_boundaries=None, boundary_exclude_distance=0, distance_weight_function=None, network_kwargs={'max_edge_distance': inf, 'min_edge_distance': 0, 'network_type': 'Delaunay'}, alpha=0.05, add_local_value_as_label=True, local_morans_label_name=None)#
Calculate the local and global Moran’s I statistic for a continuous label in the domain. Moran’s I quantifies the spatial autocorrelation of a label relative to a null hypothesis of Complete Spatial Randomness (CSR) and returned as a z-score and p-value. The local Moran’s I statistic quantifies the spatial autocorrelation for each object in the population. The global Moran’s I statistic quantifies the spatial autocorrelation for the entire population. Positive z-scores indicate clustering of similar label values whereas negative z-scores indicate dispersion of similar label values. Local p-values are corrected using the Bonferroni method. Local Moran’s I values are added as labels to the domain if add_local_value_as_label is True.
- Parameters:
- domainobject
A muspan domain object.
- populationlist or np.ndarray or query-like
The population of objects or a query to select objects.
- label_namestr
The name of the label to be analysed.
- include_boundarieslist, np.ndarray or query-like or None, optional
Boundaries to include or None to include all.
- exclude_boundarieslist, np.ndarray or query-like or None, optional
Boundaries to exclude or None to exclude none.
- boundary_exclude_distancefloat, optional
Distance to exclude around boundaries, default is 0.
- distance_weight_functioncallable or None, optional
Function to weight distances, default f(x) = 1.
- network_kwargsdict, optional
Dictionary of network generation parameters, default is {‘network_type’: ‘Delaunay’, ‘min_edge_distance’: 0, ‘max_edge_distance’: np.inf}.
- alphafloat, optional
Significance level for null rejection, default is 0.05.
- add_local_value_as_labelbool, optional
Whether to add local Moran’s I values as labels, default is True.
- local_morans_label_namestr, optional
Name for the local Moran’s I label. If not specified, this will default to ‘Local Moran I statistic - {label_name}’, where {label_name} is the label specified above.
- Returns:
- global_morans_i_zscorefloat
Z-score for the global Moran’s I statistic.
- global_morans_i_pvalfloat
P-value for the global Moran’s I statistic.
- local_morans_i_zscorendarray
Array of z-scores for the local Moran’s I statistic.
- local_morans_i_pvalndarray
Array of p-values for the local Moran’s I statistic.
- object_indicesndarray
Array of object indices used in the analysis.
- Raises:
- ValueError
If the label does not exist or is not continuous, or if distance_weight_function is not callable.
- Warnings
If the number of objects is less than 30, a warning is issued about statistical validity.