Getting data for Champaign-IL
This exercise will use data from Champaign-IL neighborhoods that come from the American Community Survey 5-year estimates (2015-2019). The first step is to load the "acs5"
variables and find the codes related to racial composition information.
library(tidyverse)
library(tidycensus)
<-load_variables(2019, "acs5")
var_2019#View(var_2019)
Use View(var_2019)
to find the ones related to total, white, and black populations. You are looking concept
RACE and labels “Estimate!!Total:”, “Estimate!!Total:!!White alone” and “Estimate!!Total:!!Black or African American alone”. There you have Blacks and Whites who declared a single race. It is important to note that people who identify their origin as Hispanic, Latino, or Spanish may be of any race.
The get_acs()
with geometry=T
allows you to get coordinates and make maps. I set geography="tract"
to use data from census tracts (treated as neighborhoods here).
<-get_acs(geography = "tract",
chambana variables = c(total="B02001_001",
black="B02001_003",
white="B02001_002"),
state = "IL",
county="Champaign County",
geometry = TRUE,
year=2019,
output="wide")
View(chambana)
The following code sets the shares of whites and blacks in each census tract in Champaign County.
<-chambana%>%
chambanamutate(black_share=blackE/totalE,white_share=whiteE/totalE)
max(chambana$black_share)
## [1] 0.7498664
As one can see, there are no ghettos in Champaign when setting the threshold as 80% of minority share.
Calculating the RDI for Champaign-IL
Here is the Racial Dissimilarity Index formula:
\[ RDI= \frac{1}{2}\sum_{i=1}^{n} |\underbrace{\frac{black_{i}}{black_{total}}}_\text{X}-\underbrace{\frac{white_{i}}{white_{total}}}_\text{Y}| \]
where \(\frac{black_{i}}{black_{total}}\) is the number of black people in a tract divided by the total of blacks in the area (in our case, the entire county). \(\frac{white_{i}}{white_{total}}\) is the number of whites in a neighborhood divided by the total of whites in the county. Take the absolute value of this difference for each census tract. Then, sum all those numbers and multiply by .5.
Note that this formula is different from White to Non-White Racial Dissimilarity Index calculated by FRED. If you replace blacks with nonwhites in the formula above, you get very similar numbers to FRED data. To get the nonwhites, you need to take the difference between the total population and the white population.
<-sum(chambana$whiteE)
tot_white<-sum(chambana$blackE)
tot_black#chambana$non_white<-chambana$totalE-chambana$whiteE
#tot_nonwhite<-sum(chambana$non_white)
$X<-chambana$blackE/tot_black
chambana#chambana$X<-chambana$non_white/tot_nonwhite
$Y<-chambana$whiteE/tot_white
chambana<-.5*sum(abs(chambana$X-chambana$Y))
DI*100 DI
## [1] 47.57606
The RDI for Champaign-IL county in 2015-2019 is 47.57.