segregation.inference.SingleValueTest¶
- class segregation.inference.SingleValueTest(seg_class, iterations_under_null=500, null_approach='systematic', two_tailed=True, n_jobs=-1, **kwargs)[source]¶
Statistical inference for a single segregation measure.
- Parameters:
- seg_class
segregation.singlegroup
orsegregation.multigroup
object
fitted segregation index class
- iterations_under_null
int
number of iterations under null hyphothesis
- null_approach
str
Which counterfactual approach to use when generating null hypothesis distribution. One of the following:.
bootstrap
:
Generate bootstrap replications of the units with replacement of the same size of the original data to create a distribution of the segregation index. Then the null_value argument is tested against this distribution. The null_value may be 0, or may be estimated empirically using the simulate_null function.
systematic
:
assumes that every group has the same probability with restricted conditional probabilities p_0_j = p_1_j = p_j = n_j/n (multinomial distribution).
evenness
:
Generate a distribution of segregation indices under the assumption of evenness, which assumes that each spatial unit has the same global probability of drawing elements from the minority group of the fixed total unit population (binomial distribution). Then test the observed segregation index against this distribution
person_permutation
:
Generate a distribution of segregation indices under the assumption of individual-level randomization, which randomly allocates individuals into units keeping the total population of each equal to the original.Then test the observed segregation index against this distribution
geographic_permutation
:
Generate a distribution of segregation indices under the assumption of geographit unit-level randomization, which randomly allocates the units over space keeping the original values. Then test the observed segregation index against this distribution
systematic_permutation
:
Generate a distribution of segregation indices under the assumption of systemic randomization, then randomly allocate units over space. Then test the observed segregation index against this distribution
even_permutation
:
Generate a distribution of segregation indices under the assumption of evenness, then randomly allocating the units over space. Then test the observed segregation index against this distribution
- two_tailedbool
If True, p_value is two-tailed. Otherwise, it is right one-tailed. The one-tailed p_value attribute might not be appropriate for some measures, as the two-tailed. Therefore, it is better to rely on the est_sim attribute.
- n_jobs: int, optional
number of cores to use for estimation. If -1 all available cpus will be used
- backend: str, optional
which backend to use with joblib. Options include “loky”, “multiprocessing”, or “threading”
- index_kwargs
dict
,optional
additional keyword arguments passed to the index class
- seg_class
- Attributes:
Notes
1) The different approaches for the null hypothesis affect directly the results of the inference depending on the combination of the index type of seg_class and the null_approach chosen. Therefore, the user needs to be aware of how these approaches are affecting the data generation process of the simulations in order to draw meaningful conclusions. For example, the Modified Dissimilarity (ModifiedDissim) and Modified Gini (ModifiedGiniSeg) indexes, rely exactly on the distance between evenness through sampling which, therefore, the “evenness” value for null approach would not be the most appropriate for these indexes.
Examples
Several examples can be found here https://github.com/pysal/segregation/blob/master/notebooks/inference_wrappers_example.ipynb.
- __init__(seg_class, iterations_under_null=500, null_approach='systematic', two_tailed=True, n_jobs=-1, **kwargs)[source]¶
Methods
__init__
(seg_class[, iterations_under_null, ...])plot
([color, kde, ax])Plot the distribution of simulated values and the observed index being tested.
- plot(color='darkblue', kde=True, ax=None, **kwargs)[source]¶
Plot the distribution of simulated values and the observed index being tested.
- Parameters:
- color
str
,optional
color of histogram, by default ‘darkblue’
- kdebool,
optional
Whether to plot the kernel density estimate along with the histogram, by default True
- ax
matplotlib.axes
,optional
axes object to plot onto, by default None
- kwargs
seaborn.histplot
argument
,optional
additional keyword arguments passed to seaborn’s histplot function
- color
- Returns:
matplotlib.axes
pyplot axes object