segregation.aspatial.BiasCorrectedDissim¶
-
class
segregation.aspatial.
BiasCorrectedDissim
(data, group_pop_var, total_pop_var, B=500)[source]¶ Calculation of Bias Corrected Dissimilarity index
- Parameters
- dataa pandas DataFrame
- group_pop_varstring
The name of variable in data that contains the population size of the group of interest
- total_pop_varstring
The name of variable in data that contains the total population of the unit
- Bint
The number of iterations to calculate Dissimilarity simulating randomness with multinomial distributions. Default value is 500.
Notes
Based on Allen, Rebecca, et al. “More reliable inference for the dissimilarity index of segregation.” The econometrics journal 18.1 (2015): 40-66.
Reference: [ABDW15].
Examples
In this example, we will calculate the Dissimilarity with Bias Correction (Dbc) for the Riverside County using the census tract data of 2010. The group of interest is non-hispanic black people which is the variable nhblk10 in the dataset.
Firstly, we need to perform some import the modules and the respective function.
>>> import pandas as pd >>> import geopandas as gpd >>> import segregation >>> from segregation.aspatial import BiasCorrectedDissim
Secondly, we need to read the data:
>>> # This example uses all census data that the user must provide your own copy of the external database. >>> # A step-by-step procedure for downloading the data can be found here: https://github.com/spatialucr/geosnap/blob/master/examples/01_getting_started.ipynb >>> # After the user download the LTDB_Std_All_fullcount.zip and extract the files, the filepath might be something like presented below. >>> filepath = '~/data/LTDB_Std_2010_fullcount.csv' >>> census_2010 = pd.read_csv(filepath, encoding = "ISO-8859-1", sep = ",")
Then, we filter only for the desired county (in this case, Riverside County):
>>> df = census_2010.loc[census_2010.county == "Riverside County"][['pop10','tractid']]
The value is estimated below.
>>> np.random.seed(1234) >>> bias_corrected_dissim_index = BiasCorrectedDissim(df, 'tractid', 'pop10') >>> bias_corrected_dissim_index.statistic 0.31484636081876954
- Attributes
- statisticfloat
Dissimilarity with Bias-Correction (bias correction from Allen, Rebecca et al. (2015))
- core_dataa pandas DataFrame
A pandas DataFrame that contains the columns used to perform the estimate.
-
__init__
(data, group_pop_var, total_pop_var, B=500)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(data, group_pop_var, total_pop_var)Initialize self.