Read in behavior and language biases

countries_langs <- read_csv("../../data/other/countries_lang.csv") %>%
  mutate(language_name = ifelse(language_name == "Spanish; Castilian", "Spanish", language_name),
         language_name = ifelse(language_name == "Dutch; Flemish", "Dutch", language_name))

IAT_behavior_measures <- read_csv("../behavior_IAT/IAT_behavior_measures.csv") %>%
  left_join(countries_langs %>% select(country_name, language_name, language_code)) %>%
  filter(type %in% c("country_means_D_score", 
             "country_gender_D_score", 
             "country_gender_D_score_diff", 
             "country_RT_mean",
             "country_RT_ratio")) %>%
  group_by(type, language_code, sex) %>%
  summarize(mean = mean(mean)) 

lang_bias <- read_csv("career_effect_sizes.csv") 

lang_bias_google <- read_csv("google_translate/career_effect_sizes_google.csv",
                             col_names = c("language_code",   "test",  "test_name", "lang_bias")) %>%
  filter(language_code != "he", language_code != "zu", language_code != "th") #,language_code !=  "ha",language_code !=  "id",language_code !=  "zh")


d <- left_join(IAT_behavior_measures, lang_bias) %>%
  mutate_if(is.character, as.factor) %>%
  filter(!is.na(lang_bias))

Correlation between measures

d %>%
  mutate(type2 = ifelse(type %in% c("country_gender_D_score_diff", "country_means_D_score", "country_gender_D_score"), "D-score", ifelse(type %in% c("country_RT_ratio", "country_RT_mean"), "RT", "explicit"))) %>%
ggplot( aes(x = mean, y = lang_bias, group = sex, color = sex, shape = type2)) +
  geom_label(aes(label = language_code)) +
  geom_smooth(method = "lm") +
  facet_wrap(~type, scales = "free_x", drop = T) +
  theme_bw()

d %>%
  mutate(type2 = ifelse(type %in% c("country_gender_D_score_diff", "country_means_D_score", "country_gender_D_score"), "D-score", ifelse(type %in% c("country_RT_ratio", "country_RT_mean"), "RT", "explicit"))) %>%
ggplot( aes(x = mean, y = lang_bias, group = sex, color = sex, shape = type2)) +
  geom_point() + 
  geom_smooth(method = "lm") +
  facet_wrap(~type, scales = "free_x", drop = T) +
  theme_bw()