helper functions (hidden)

load files (hidden)

reformat and merge looking times with jspsych output (hidden)

Exclusions

# remove looking times less than 1 sec 
complete_df <- complete_df  %>% 
  filter(
    looking_time_2000 > 1, # remove looking times less than 1 sec 
    looks_error_2000_s == 0, # remove looking times less than 1 sec
    valid,
    !(subject_num ==  '6' & session_num == "1" & trial_num >= 4), # subj 6, sess 1 exclude trials 4,5,6
    !(subject_num ==  '9' & session_num == "1"), # subj 9, sess 1 exclude completely
    !(subject_num ==  '13' & session_num == "1"), # subj 13, session 1 exclude completely
    !(subject_num ==  '17' & session_num == "1" & trial_num == 6), # subj 17 sess 1 exclude trial 6
    !(subject_num ==  '18' & session_num == "1" & trial_num == 3), # subj 18 sess 1 exclude trial 3
    !(subject_num ==  '22' & session_num == "1" & trial_num == 6), # subj 22 sess 1 exclude trial 6
    !(subject_num ==  '27' & session_num == "1" & trial_num == 4), # subj 27 sess 1 exclude trial 4
    !(subject_num ==  '4' & session_num == "2" & trial_num == 6), # subj 4, sess 2 exclude trial 6
    !(subject_num ==  '6' & session_num == "2"), # subj 6, sess 2 exclude completely
    !(subject_num ==  '10' & session_num == "2" & trial_num == 5),# subj 10 sess 2 exclude trial 5
    !(subject_num ==  '12' & session_num == "2" & trial_num == 6), # subj 12 sess 2 exclude trial 6
    !(subject_num ==  '19' & session_num == "2" & trial_num == 6), # subj 19 sess 2 exclude trial 6
   !(subject_num ==  '16' & session_num == "2" & trial_num >= 4), # subj 16 sess 2 exclude trial 4,5,6
  !(subject_num ==  '34' & session_num == "2" & trial_num >= 5)# subj 34 sess 2 exclude trial 5,6
  )

Descriptives on test trials

# only test trials (and reorder some stuff)
test_df <- complete_df %>% filter(fam_or_test == 'test') %>% group_by(subject_num) %>% mutate(normLT = (looking_time_2000-mean(looking_time_2000))/sd(looking_time_2000)) %>% select(c(session_number, subject_num, block_number, block_type, fam_duration), everything())

# check how many subjects are left
length(unique(complete_df$subject_num))
## [1] 35
# check distribution of standard vs deviant trials 
test_df %>% group_by(block_type) %>% dplyr::summarise(n=n())
## # A tibble: 2 × 2
##   block_type     n
##   <fct>      <int>
## 1 Dev          136
## 2 Std          136
# how many trials per fam duration
test_df %>% group_by(fam_duration) %>% dplyr::summarise(n_trial = n()) 
## # A tibble: 3 × 2
##   fam_duration n_trial
##   <fct>          <int>
## 1 3                 94
## 2 5                 85
## 3 7                 93
# number of trials by complexity
test_df %>% group_by(complexity) %>% dplyr::summarise(n = n())
## # A tibble: 2 × 2
##   complexity     n
##   <chr>      <int>
## 1 complex      126
## 2 simple       146
# number of trials by session
test_df %>% group_by(session_number) %>% dplyr::summarise(n = n())
## # A tibble: 2 × 2
##   session_number     n
##            <dbl> <int>
## 1              1   145
## 2              2   127
# number of trials by block number
test_df %>% group_by(block_number) %>% dplyr::summarise(n = n())
## # A tibble: 6 × 2
##   block_number     n
##          <dbl> <int>
## 1            1    52
## 2            2    50
## 3            3    49
## 4            4    49
## 5            5    33
## 6            6    39

check for sampling imbalance

## `summarise()` has grouped output by 'block_number', 'block_type', 'fam_duration'. You can override using the `.groups` argument.
## Joining, by = c("block_number", "block_type", "fam_duration", "complexity")

Plot results

ggplot(test_df, aes(x=looking_time_2000)) + geom_histogram(bins = 20) + xlab('Looking time in (s)')

# calculate means
mean_df <- summarySE(test_df, measurevar="looking_time_2000", groupvars=c("block_number"))

ggplot(test_df, aes(x=block_number, y = looking_time_2000)) + 
  geom_jitter(alpha = 0.2, width = 0.1) + stat_summary(fun.data = "mean_cl_boot", geom = "line", position = position_dodge(width = .1))  + stat_summary(fun.data = "mean_cl_boot", geom = "pointrange", position = position_dodge(width = .1)) + xlab('Block Number') + ylab('LT in sec') + theme_classic(base_size = 15)

ggplot(test_df, aes(x=block_type, y=looking_time_2000)) + geom_jitter(width = 0.1, alpha = 0.2)  + stat_summary(fun.data = "mean_cl_boot", geom = "pointrange", position = position_dodge(width = .1)) + xlab('Test trial type') + ylab('Looking Time (s)') + theme_classic(base_size = 15)

ggplot(test_df, aes(x=fam_duration, y=looking_time_2000, color = fam_duration)) + geom_jitter(width = 0.1, alpha = 0.2)  + stat_summary(fun.data = "mean_cl_boot", geom = "pointrange", position = position_dodge(width = .1)) +  xlab('# of Fam Trials') + ylab('Looking Time (s)') + labs(color = '# of Fam Trials') + theme_grey(base_size = 14) + theme(legend.position="none", axis.text=element_text(size=15))

ggplot(test_df, aes(x=block_type, y=log(looking_time_2000), group=complexity, color = complexity)) + geom_point(alpha=0.2, position = position_dodge(width = .1)) + facet_grid(~fam_duration) + xlab('Trial type') + ylab('log seconds') + labs(color = '# of Fam Trials') + theme_classic() + theme(strip.text.x = element_text(size = 14, colour = "black")) + stat_summary(fun.data = "mean_cl_boot", geom = "line", position = position_dodge(width = .1)) + 
  stat_summary(fun.data = "mean_cl_boot", geom = "pointrange", position = position_dodge(width = .1))