Libraries.

library(Rmisc)
library(tidyverse)
library(here)
library(lme4)
library(lsr)
library(ggplot2)
library(viridis)
library(readxl)
library(sjstats)
library(reshape2)
library(coin)
library(ggbeeswarm)
library(praise)
library(langcog)
library(ggpubr)
library(ggthemes)
library(gganimate)
library(lmerTest)
library(janitor)
library(PupillometryR)
library(ggpp)
library(plotly)

Read in model.

model = read.csv("BI_allTrials.csv") %>%
  clean_names()

Tidy model.

tidy = model %>% 
  pivot_longer(cols=coach_comp_belief:belief_unbiased, names_to = "output", values_to = "values")

tidy2 = model %>%
  separate(col=coach_obs, into=c("obs1","obs2","obs3"), sep="]") %>%
  mutate(obs1 = str_sub(obs1, 10),
         obs2 = str_sub(obs2, 11),
         obs3 = str_sub(obs3, 11),
         obs1 = str_remove(obs1, ", result: "),
          obs2 = str_remove(obs2, ", result: "),
          obs3 = str_remove(obs3, ", result: ")) %>%
  rowwise() %>%
  mutate(easy_miss = str_detect(obs1, "1miss") + str_detect(obs2, "1miss") + str_detect(obs3, "1miss"),
         med_miss = str_detect(obs1, "2miss") + str_detect(obs2, "2miss") + str_detect(obs3, "2miss"),
         hard_miss = str_detect(obs1, "3miss") + str_detect(obs2, "3miss") + str_detect(obs3, "3miss"),
         easy_hit = str_detect(obs1, "1hit") + str_detect(obs2, "1hit") + str_detect(obs3, "1hit"),
         med_hit = str_detect(obs1, "2hit") + str_detect(obs2, "2hit") + str_detect(obs3, "2hit"),
         hard_hit = str_detect(obs1, "3hit") + str_detect(obs2, "3hit") + str_detect(obs3, "3hit"))
## Warning: Expected 3 pieces. Additional pieces discarded in 648 rows [1, 2, 3, 4,
## 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].
plot_ly(filter(tidy2, coach_rec == "1"), x=~obs1, y=~obs2, z=~obs3, color=~coach_bias) %>%
  layout(title = 'Coach recommends easy')
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
plot_ly(filter(tidy2, coach_rec == "2"), x=~obs1, y=~obs2, z=~obs3, color=~coach_bias) %>%
    layout(title = 'Coach recommends medium')
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
plot_ly(filter(tidy2, coach_rec == "3"), x=~obs1, y=~obs2, z=~obs3, color=~coach_bias) %>%
    layout(title = 'Coach recommends hard')
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode