Set params
MIN_PARTICIPANTS_PER_COUNTRY <- 400
Read in IAT data.
#d <- haven::read_sav("../data/Race IAT.public.2016.sav")
#write_feather(d, "../data/Race IAT.public.2016.feather")
raw_iat_behavioral <- read_feather("../data/Race IAT.public.2016.feather") %>%
rename(mixed_countryres = countryres) %>%
mutate(mixed_countryres = trimws(mixed_countryres)) %>%
select(D_biep.White_Good_all, birthsex, mixed_countryres, PCT_error_3467,
Mn_RT_all_3467, Mn_RT_all_3, Mn_RT_all_4, Mn_RT_all_6,
Mn_RT_all_7, anes1, N_ERROR_3, N_ERROR_4,
N_ERROR_6, N_ERROR_7, N_3, N_4, N_6, N_7, raceomb_002, raceomb, raceombmulti) %>%
rename(overall_iat_D_score = D_biep.White_Good_all) %>%
data.table()
country_key <- read_csv("../../../data/other/mixed_countryres_to_country_res_key.csv")
raw_iat_behavioral_complete <- raw_iat_behavioral %>%
filter(!is.na(mixed_countryres),
mixed_countryres != ".",
mixed_countryres != "nu", # not clear what this refers to (it's lower case and not in codebook- Niue seems unlikely)
!is.na(overall_iat_D_score)) %>%
left_join(country_key) %>%
select(-mixed_countryres)
country_ns <- raw_iat_behavioral_complete %>%
left_join(country_key) %>%
count(countryres) %>%
filter(n >= MIN_PARTICIPANTS_PER_COUNTRY) %>%
arrange(-n) %>%
filter(countryres != "NA")
raw_iat_behavioral_complete_dense_country <- raw_iat_behavioral_complete %>%
filter(countryres %in% country_ns$countryres)
# same exclusions as Nosek, Banjali, & Greenwald (2002), pg. 104.
iat_behavioral <- raw_iat_behavioral_complete_dense_country %>%
filter(Mn_RT_all_3467 <= 1500, # RTs
Mn_RT_all_3 <= 1800,
Mn_RT_all_4 <= 1800,
Mn_RT_all_6 <= 1800,
Mn_RT_all_7 <= 1800) %>%
filter(N_ERROR_3/N_3 <=.25, # errors
N_ERROR_4/N_4 <=.25,
N_ERROR_6/N_6 <=.25,
N_ERROR_7/N_7 <=.25)
There are 47 with at least 400 participants. This includes 1002080 participants.
country_means_race <- iat_behavioral %>%
group_by(countryres) %>%
multi_boot_standard(col = "overall_iat_D_score")
Plot
country_means_race_with_name <- country_means_race %>%
mutate(country_name = countrycode(countryres,
"iso2c",
"country.name")) %>%
mutate(country_name = replace(country_name,
countryres == "UK", "UK"))
ggplot(country_means_race_with_name, aes(x = reorder(country_name, mean),
y = mean)) +
geom_bar(stat = "identity", position = "dodge") +
ggtitle("IAT race bias (2005 - 2016 data)") +
ylab("IAT race bias") +
xlab("Country") +
geom_linerange(aes(ymin = ci_lower, ymax = ci_upper),
position = position_dodge(width = .9)) +
theme_bw() +
theme(axis.text.x = element_text(angle = 60, hjust = 1),
legend.position = "none")
map_world <- map_data(map = "world") %>%
mutate(country_name = region) %>%
mutate(country_name = fct_recode(country_name,
`United States of America` = "USA",
`Russian Federation` = "Russia",
`Republic of Korea` = "South Korea"))
map_data <- left_join(map_world, country_means_race_with_name) %>%
rename(race_bias = mean) %>%
filter(lat > -57,
long > -165)
ggplot(map_data, aes(x = long, y = lat,
group = group,
fill = race_bias)) +
scale_fill_gradient2(midpoint = mean(map_data$race_bias, na.rm = T),
low = "blue", high = "red") +
#scale_fill_continuous(low ="white", high = "blue") +
geom_polygon(color = "black", size = .1) +
#geom_polygon() +
theme_bw()
Migration index (bigger values -> less diverse)
diversity = read_csv("../data/countryDiversity_parsed.txt") %>%
rename(homogeneity = diag) %>%
mutate(country_name = countrycode(wbcode,
"wb_api3c",
"country.name"),
country_code = countrycode(wbcode,
"wb_api3c",
"iso2c"))
map_data <- left_join(map_world, diversity, by = c("country_name")) %>%
filter(lat > -57,
long > -165)
ggplot(map_data, aes(x = long, y = lat,
group = group,
fill = homogeneity)) +
scale_fill_gradient2(
low = "blue", high = "red") +
#scale_fill_continuous(low ="white", high = "blue") +
geom_polygon(color = "black", size = .1) +
#geom_polygon() +
theme_bw()
both <- left_join(country_means_race, diversity, by = c("countryres" = "country_code")) %>%
ungroup()
ggplot(both, aes(x = homogeneity, y = mean)) +
ylab("race bias") +
geom_text(aes(label = countryres)) +
geom_smooth(method = "lm")+
theme_bw()
cor.test(both$homogeneity, both$mean, method = "spearman")
##
## Spearman's rank correlation rho
##
## data: both$homogeneity and both$mean
## S = 10915, p-value = 0.1317
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 0.230792