Data prep

MERGED_DATA_PATH <- here("data/2_merged/merged_all.csv")
d <- read_csv(MERGED_DATA_PATH)
clean_d <- read_csv(here("writeups/CCRR_CogSci/cogsci_data/tidy_main.csv"))
order_d <- d %>% 
  rowwise() %>% 
  mutate(task_name = case_when(
    variable_type == "raven" ~ "RV", 
    grepl("ebb", trial_type) ~ "EBB", 
    grepl( "free-description", trial_type) ~ "FD",
    grepl("RMTS", trial_type) ~ "RMTS", 
    grepl("attribution", trial_type) ~ "CA", 
    grepl("pen-choice", trial_type) ~ "PC", 
    grepl( "konva",trial_type) ~ "SI",
    grepl( "horizon",trial_type) ~ "HZ"
  )) %>% 
  select(subject, task_name) %>% 
  distinct(subject, task_name) %>% 
   filter(!is.na(task_name)) %>% 
  group_by(subject) %>% 
  mutate(
    task_order = row_number()
  ) 
order_info_d <- order_d %>% 
  left_join(order_d %>% 
              filter(task_name == "FD") %>% 
              rename(fd_position = task_order) %>% 
              select(subject, fd_position), by = "subject") %>% 
  mutate(location_relative_to_fd = case_when(
    task_order < fd_position ~ "before", 
    task_order > fd_position ~ "after", 
    task_order == fd_position ~ "FD"
  )) %>% 
  select(-fd_position) %>% 
  mutate(task_name = case_when(
    task_name == "PC" ~ "CP", 
    TRUE ~ task_name
  ))
d_with_order_info <- clean_d %>%  
  left_join(order_info_d %>% 
              ungroup() %>% 
              filter(subject %in% order_info_d$subject), 
             by = c("subject", "task_name"))

a remidner that the pen choice task can be either 6 or 7 because we package SI and HZ together

d_with_order_info %>% 
  filter(task_order == 7)
## # A tibble: 421 x 10
##       X1 subject    culture task_name task_info trial_info resp_type        resp
##    <dbl> <chr>      <chr>   <chr>     <chr>     <chr>      <chr>           <dbl>
##  1    91 SS1609057… CN      SI        SI        SI         inflation_sc…   1.29 
##  2    92 SS1609057… CN      SI        SI        SI         inflation_sc…  35.2  
##  3    93 SS1609062… CN      SI        SI        SI         inflation_sc…   1.02 
##  4    94 SS1609062… CN      SI        SI        SI         inflation_sc…   2.23 
##  5   115 SS1609139… CN      SI        SI        SI         inflation_sc…   0.425
##  6   116 SS1609139… CN      SI        SI        SI         inflation_sc… -51.1  
##  7   135 SS1609214… CN      SI        SI        SI         inflation_sc…   1.04 
##  8   136 SS1609214… CN      SI        SI        SI         inflation_sc…   2.16 
##  9   141 SS1609229… CN      SI        SI        SI         inflation_sc…   0.956
## 10   142 SS1609229… CN      SI        SI        SI         inflation_sc…  -3.75 
## # … with 411 more rows, and 2 more variables: task_order <int>,
## #   location_relative_to_fd <chr>

Look at each task

CA

order effect

d_with_order_info %>% 
  filter(task_name == "CA") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_sum = sum(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = task_order, y = resp_sum, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  facet_wrap(~ resp_type) + 
  theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "CA") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_sum = sum(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = location_relative_to_fd, y = resp_sum, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  facet_wrap(~ resp_type) + 
  theme_classic() 

RV

order effect

d_with_order_info %>% 
  filter(task_name == "RV") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_acc = mean(resp)) %>% 
  ggplot(aes(x = task_order, y = resp_acc, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  geom_smooth(method = "lm") + 
   theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "RV") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_acc = mean(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = location_relative_to_fd, y = resp_acc, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  theme_classic() 

EBB

order effect

d_with_order_info %>% 
  filter(task_name == "EBB") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_acc = mean(resp)) %>% 
  ggplot(aes(x = task_order, y = resp_acc, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  geom_smooth(method = "lm") + 
   theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "EBB") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_acc = mean(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = location_relative_to_fd, y = resp_acc, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  theme_classic() 

HZ

order effect

d_with_order_info %>% 
  filter(task_name == "HZ") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  filter(resp_type == "hz_height") %>% 
  summarise(
    horizon_height = mean(resp)) %>% 
  ggplot(aes(x = task_order, y = horizon_height, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  geom_smooth(method = "lm") + 
   theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "HZ") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  filter(resp_type == "hz_height") %>% 
  summarise(
    horizon_height = mean(resp)) %>% 
  ggplot(aes(x = location_relative_to_fd, y = horizon_height, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  theme_classic() 

SI

order effect

d_with_order_info %>% 
  filter(task_name == "SI") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  filter(resp_type == "inflation_score_ratio") %>% 
  summarise(
    inflation_score_ratio = mean(resp)) %>% 
  ggplot(aes(x = task_order, y = inflation_score_ratio, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  geom_smooth(method = "lm") + 
   theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "SI") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  filter(resp_type == "inflation_score_ratio") %>% 
  summarise(
    inflation_score_ratio = mean(resp)) %>% 
  ggplot(aes(x = location_relative_to_fd, y = inflation_score_ratio, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  theme_classic() 

FD

order effect

d_with_order_info %>% 
  filter(task_name == "FD") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    resp_sum = sum(resp), 
    subject_n = n()) %>% 
  filter(!grepl("full", resp_type)) %>% 
  ggplot(aes(x = task_order, y = resp_sum, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  facet_wrap(~ resp_type) + 
  theme_classic() 

RMTS

order effect

d_with_order_info %>% 
  filter(task_name == "RMTS") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    proportion_relation_match = mean(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = task_order, y = proportion_relation_match, color = culture)) + 
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  facet_wrap(~ resp_type) + 
  theme_classic() 

relation to FD

d_with_order_info %>% 
  filter(task_name == "RMTS") %>% 
  group_by(subject, culture, resp_type, task_order, location_relative_to_fd) %>% 
  summarise(
    proportion_relation_match = mean(resp), 
    subject_n = n()) %>% 
  ggplot(aes(x = location_relative_to_fd, y = proportion_relation_match, color = culture)) + 
  geom_jitter(alpha = .3) + 
 stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .3)) + 
  facet_wrap(~ resp_type) + 
  theme_classic()