A common inquiry in demographic studies involves assessing segregation levels between racial groups. For example, how segregated is the Hispanic population? Traditionally, the dissimilarity index D assesses segregation between two groups. In other studies, authors used multiracial information theory index H to assess the segregation level between one racial group and the remaining groups (i.e., Elbers, 2022.
The example shows how NRGD2020 and the raceland
package
can be used to determine the level of segregation between a racial group
and the remaining racial groups inhabiting the area.
The inputs for calculating racial segregation metrics for a particular racial group (i.e., Hispanics/Latinos, or Blacks) are RL grid racial ID and RL grid population density from NRGD2020. This example uses two layers included in the Atlanta datasetAtlanta dataset can be downloaded from http://www.socscape.edu.pl/index.php?id=nrgd)
library(terra)
library(raceland)
#set working directory to the folder containing data using function setwd("")
##setwd("")
#read RL grid racial ID to R using terra package
= rast("Atlanta_dataset/RL_grids/rl_msa.tif")
rl #read RL grid population density to R using terra package
= rast("Atlanta_dataset/RL_grids/rd_msa.tif")
rd
######## CALCULATE SEGREGATION METRICS FOR HISPANICS/LATIONOS ########
#reclassify data to two categories - Hispanics and non-Hispanic population.
# RL grid racial ID consists of 6 categories: 1 - Native Americans, 2 - Asians, 3 - Blacks, 4 - Hispanics, 5 - others, 6 - Whites)
# Assign 1 to HISPANIC sub-population and 0 to all other racial groups.
= cbind(c(1,2,3,4,5,6), c(0, 0, 0, 1, 0,0))
rcl = classify(rl, rcl)
rl_hisp
#calculate diversity and segregation metrics using raceland package
= calculate_metrics(rl_hisp, rd, fun = "mean", threshold = 1)
metr #return metrics in a user-friendly format
= c(MI = metr$mutinf, NMI = metr$mutinf/metr$ent) Hispanics
######## CALCULATE SEGREGATION METRICS FOR BLACK ########
#reclassify data to two categories - Black and non-black population.
# RL grid racial ID consists of 6 categories: 1 - Native Americans, 2 - Asians, 3 - Blacks, 4 - Hispanics, 5 - others, 6 - Whites)
# Assign 1 to Black sub-population and 0 to all other racial groups.
= cbind(c(1,2,3,4,5,6), c(0, 0, 1, 0, 0,0))
rcl = classify(rl, rcl)
rl_black
#calculate diversity and segregation metrics using raceland package
= calculate_metrics(rl_black, rd, fun = "mean", threshold = 1)
metr #return segregation metrics in a user-friendly format
= c(MI = metr$mutinf, NMI = metr$mutinf/metr$ent) Black
plot(rl_black, col = c("#ececec", "#6EBE44"), legend = FALSE, axes = FALSE, main = "BLACKS")
plot(rl_hisp, col = c("#ececec", "#7E69AF"), legend = FALSE, axes = FALSE, main = "HISPANICS")
The table shows:
library(kableExtra)
= rbind(Black, Hispanics)
res kable_classic(kbl(round(res, 4)), full_width = F)
MI | NMI | |
---|---|---|
Black | 0.1322 | 0.1447 |
Hispanics | 0.0220 | 0.0416 |