1 Set up R environment

library(tidyverse)
library(ggplot2)
library(ggpubr)
library(plyr)

Set the R working drectory to the main experiment directory.

setwd("/Users/adambarnas/Box/CogStyles_IB")  

2 Sona Subjects

2.1 Read-in datafiles

Read in the individual subject files (saved automatically on the server as csv files).

Get a count of the number of subjects.

nrow(tbl_all_sona %>% distinct(ID,.keep_all = FALSE))
## [1] 18

2.2 Cognitive Styles

Split up the cognitive styles stimuli nomenclature to task, answer, and number. Filter the two cognitive styles tasks.

tbl_all_cog_style_sona <- tbl_all_sona %>%
  separate(stim1,into=c('task', 'answer', 'number')) %>% 
  filter(task == 'matching' | task == 'embedded')
tbl_all_cog_style_sona = subset(tbl_all_cog_style_sona, select = -c(ITI,stimFormat,button1,keyboard,key,responseWindow,head,responseType,randomPick,responseOptions,pageBreak,required,responseCode,correct))

2.2.1 Analyze accuracy

In the matching figures task, subjects were instructed to press ‘F’ if the two complex shapes were the same and ‘J’ if the two complex shapes were different. Trials will be labeled 1 for correct responses (‘F’ for same objects and ‘J’ for different objects) and 0 for incorrect responses (‘F’ for different objects and ‘J’ for same objects).

In the embedded figures task, subjects were instructed to press ‘F’ if the simple shape is within the complex shape and ‘J’ if the the simple shape is not within the complex shape. Trials will be labeled 1 for correct responses (‘F’ for simple within complex and ‘J’ for simple not within complex) and 0 for incorrect responses (‘F’ simple not within complex and ‘J’ simple within complex).

tbl_all_cog_style_sona$acc = "filler"

for (i in 1:length(tbl_all_cog_style_sona$ID)){
  if (tbl_all_cog_style_sona$task[i] == "matching"){
    if (tbl_all_cog_style_sona$answer[i] == "same"){
      if (tbl_all_cog_style_sona$response[i] == "f"){
        tbl_all_cog_style_sona$acc[i] = 1
    } else {
        tbl_all_cog_style_sona$acc[i] = 0
    }
    } else {
      if (tbl_all_cog_style_sona$response[i] == "j"){
        tbl_all_cog_style_sona$acc[i] = 1
    } else {
        tbl_all_cog_style_sona$acc[i] = 0
    }
  }
  }
  if (tbl_all_cog_style_sona$task[i] == "embedded"){
    if (tbl_all_cog_style_sona$answer[i] == "yes"){
      if (tbl_all_cog_style_sona$response[i] == "f"){
        tbl_all_cog_style_sona$acc[i] = 1
    } else {
        tbl_all_cog_style_sona$acc[i] = 0
    }
    } else {
      if (tbl_all_cog_style_sona$response[i] == "j"){
        tbl_all_cog_style_sona$acc[i] = 1
    } else {
        tbl_all_cog_style_sona$acc[i] = 0
    }
  }
  }
}

2.2.2 Plot accuracy

tbl_all_cog_style_acc_sona <- tbl_all_cog_style_sona %>%
  group_by(ID,task,acc) %>%
  dplyr::summarize(counts = n()) %>%
  spread(acc,counts) %>% 
  mutate(total = rowSums(.[3:4], na.rm = TRUE))
colnames(tbl_all_cog_style_acc_sona) <- c("ID", "task", "inacc", "acc", "total")
tbl_all_cog_style_acc_sona[is.na(tbl_all_cog_style_acc_sona)] <- 0
tbl_all_cog_style_acc_sona$rate <- tbl_all_cog_style_acc_sona$acc / tbl_all_cog_style_acc_sona$total

tbl_all_cog_style_acc_sona %>%
  ggbarplot("ID", "rate", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + rotate_x_text() + geom_hline(yintercept = .5, linetype = 2)

tbl_all_cog_style_acc_sona %>%
  ggbarplot("task", "rate", add = "mean_se",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + geom_hline(yintercept = .5, linetype = 2)

embedded_chance_sona <- tbl_all_cog_style_acc_sona %>% 
  filter(task =="embedded")
embedded_chance_sona <-t.test(embedded_chance_sona$rate, mu = .50, alternative="greater")
embedded_chance_sona
## 
##  One Sample t-test
## 
## data:  embedded_chance_sona$rate
## t = 15.597, df = 17, p-value = 8.324e-12
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.8319395       Inf
## sample estimates:
## mean of x 
## 0.8736111
matching_chance_sona <- tbl_all_cog_style_acc_sona %>% 
  filter(task =="matching")
matching_chance_sona <-t.test(matching_chance_sona$rate, mu = .50, alternative="greater")
matching_chance_sona
## 
##  One Sample t-test
## 
## data:  matching_chance_sona$rate
## t = 14.77, df = 17, p-value = 1.978e-11
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.8014245       Inf
## sample estimates:
## mean of x 
## 0.8416667
tbl_all_cog_style_acc_sona %>% 
  with(t.test(rate~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  rate by task
## t = 1.2023, df = 17, p-value = 0.2457
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.02411098  0.08799987
## sample estimates:
## mean of the differences 
##              0.03194444

2.2.3 Remove subjects below chance

tbl_all_cog_style_acc_sona <- subset(tbl_all_cog_style_acc_sona, select = c(ID, task, rate))
tbl_all_cog_style_acc_sona_wide <- tbl_all_cog_style_acc_sona %>%
  spread(task,rate)

tbl_all_cog_style_acc_sona <- tbl_all_cog_style_acc_sona_wide %>%
  filter(embedded > 0.5 & matching > 0.5)

tbl_all_cog_style_acc_sona <- gather(tbl_all_cog_style_acc_sona, task, rate, embedded:matching, factor_key=TRUE)

tbl_all_cog_style_acc_sona %>%
  ggbarplot("ID", "rate", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + rotate_x_text() + geom_hline(yintercept = .5, linetype = 2)

tbl_all_cog_style_acc_sona %>%
  ggbarplot("task", "rate", add = "mean_se",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + geom_hline(yintercept = .5, linetype = 2)

embedded_chance_sona <- tbl_all_cog_style_acc_sona %>% 
  filter(task =="embedded")
embedded_chance_sona <-t.test(embedded_chance_sona$rate, mu = .50, alternative="greater")
embedded_chance_sona
## 
##  One Sample t-test
## 
## data:  embedded_chance_sona$rate
## t = 15.597, df = 17, p-value = 8.324e-12
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.8319395       Inf
## sample estimates:
## mean of x 
## 0.8736111
matching_chance_sona <- tbl_all_cog_style_acc_sona %>% 
  filter(task =="matching")
matching_chance_sona <-t.test(matching_chance_sona$rate, mu = .50, alternative="greater")
matching_chance_sona
## 
##  One Sample t-test
## 
## data:  matching_chance_sona$rate
## t = 14.77, df = 17, p-value = 1.978e-11
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.8014245       Inf
## sample estimates:
## mean of x 
## 0.8416667
tbl_all_cog_style_acc_sona %>% 
  with(t.test(rate~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  rate by task
## t = 1.2023, df = 17, p-value = 0.2457
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.02411098  0.08799987
## sample estimates:
## mean of the differences 
##              0.03194444

2.2.4 Plot RTs

tbl_all_cog_style_rts_sona <- tbl_all_cog_style_sona[(tbl_all_cog_style_sona$ID %in% tbl_all_cog_style_acc_sona$ID),] %>% 
  filter(acc == 1)

tbl_all_cog_style_rts_sona %>%
  ggbarplot("ID", "RT", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), add = "median", position = position_dodge(0.8), ylab = "Median RT (ms)", ylim = c(0,8000)) + rotate_x_text()

tbl_all_cog_style_rts_sona %>%
  ggbarplot("task", "RT", add = "median",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), position = position_dodge(0.8), order = c("embedded", "matching"), ylab = "Median RT (ms)", ylim = c(0,5000))

tbl_all_cog_style_rts_median_sona <- tbl_all_cog_style_rts_sona %>%
  group_by(ID,task) %>%
  dplyr::summarize(median_rt = median(RT, na.rm=TRUE))

tbl_all_cog_style_rts_median_sona %>% 
  with(t.test(median_rt~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  median_rt by task
## t = -3.9182, df = 17, p-value = 0.001107
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2848.1293  -854.4262
## sample estimates:
## mean of the differences 
##               -1851.278

2.2.5 Compute cognitive style ratio

The wholist-analytic ratio is calculated by dividing the median response latency to items in the matching figures task (wholist) by the median response latency to items in the embedded figures task (analytic) A ratio of below 1 indicates that an individual responded relatively faster to the matching figure items, corresponding to a wholist profile; a ratio of above 1 indicates that an individual responded relatively faster to the embedded figure items, corresponding to a analytic profile.

tbl_all_cog_style_rts_median_sona <- tbl_all_cog_style_rts_median_sona %>% 
  spread(task, median_rt)
tbl_all_cog_style_rts_median_sona$ratio <- tbl_all_cog_style_rts_median_sona$matching / tbl_all_cog_style_rts_median_sona$embedded

tbl_all_cog_style_rts_median_sona$style = "filler"
for (i in 1:length(tbl_all_cog_style_rts_median_sona$ID)){
  if (tbl_all_cog_style_rts_median_sona$ratio[i] > 1){
    tbl_all_cog_style_rts_median_sona$style[i] = "analytic"
  } else {
    tbl_all_cog_style_rts_median_sona$style[i] = "wholist"
  }
}

tbl_all_cog_style_rts_median_sona %>%
  ggbarplot("ID", "ratio", fill = "#f7a800", color = "#f7a800", ylim = c(0,5), ylab = "Median wholist-analytic ratio") + rotate_x_text() + geom_hline(yintercept = 1, linetype = 2)

table(tbl_all_cog_style_rts_median_sona$style)
## 
## analytic  wholist 
##       15        3

2.3 IB performance

tbl_all_IB_sona <- tbl_all_sona %>% 
  filter(grepl('Did you notice|item', head))
tbl_all_IB_sona = subset(tbl_all_IB_sona, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

2.3.1 Noticers vs. Non-noticers

tbl_all_notice_sona <- tbl_all_IB_sona %>% 
  filter(grepl('items', head))
table(tbl_all_notice_sona$response)
## 
##       No Not sure      Yes 
##        4        3       11

2.3.2 Unexpected event description

tbl_all_event_sona <- tbl_all_IB_sona %>% 
  filter(grepl('moved', head))
tbl_all_event_sona <- cbind.data.frame(tbl_all_event_sona[1], tbl_all_event_sona[6])
knitr::kable(tbl_all_event_sona)
ID response
205396 it was the plus sign (+) and it moved from the right hand side towards the left hand side of the screen.
205204 I noticed the plus sign moving across the screen. It moved from right to left across the center line.
205060 the plus sign, moved from right to left, down the horizontal line
205420 the + moves horizontally passing the center of the box.
205255 I feel like I saw the + a few times but did not pay attention to its movement
205189 Plus sign horizontally
205057 I might have seen a + sign but I don’t really remember.
204988 I think I saw + but I am not sure how it moved.
205315 Ts and Ls
205408 +
205051 n/a
204949 The cross on the right.
205306 I’m not sure, but the + might have moved with the letters.
205084 I didn’t see anything unusual
205324 I have no idea. Maybe the black letters were erased so we only had to focus on the white letters.
205225 the middle, plus sign
205429 The cross moved horizontally along the line that the letters were crossing.
205432 X

2.4 Post IB questions

2.4.1 Expecting an unexpected event

tbl_all_expecting_sona <- tbl_all_sona %>% 
  filter(grepl('Before', head))
tbl_all_expecting_sona = subset(tbl_all_expecting_sona, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

table(tbl_all_expecting_sona$response)
## 
##  No Yes 
##  14   4

2.4.2 Familiarity with IB experiments

tbl_all_familiarity_sona <- tbl_all_sona %>% 
  filter(grepl('gorilla', head))
tbl_all_familiarity_sona = subset(tbl_all_familiarity_sona, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

table(tbl_all_familiarity_sona$response)
## 
##  No Yes 
##   4  14

2.5 Cognitive style ratio predicting IB

2.5.1 Logistic regression (Continuous predictor, dichotomous outcome)

tbl_log_reg_sona <- merge(tbl_all_cog_style_rts_median_sona, tbl_all_notice_sona, by = "ID")
tbl_log_reg_sona = subset(tbl_log_reg_sona, select = -c(rowNo,type,head,timestamp,RT,correct))
tbl_log_reg_sona[tbl_log_reg_sona == "Yes"] <- 1
tbl_log_reg_sona[tbl_log_reg_sona == "No"] <- 0
tbl_log_reg_sona[tbl_log_reg_sona == "Not sure"] <- 0
names(tbl_log_reg_sona)[names(tbl_log_reg_sona)=="response"] <- "notice"
tbl_log_reg_sona$notice <- as.numeric(tbl_log_reg_sona$notice)

log_reg_sona <- glm(notice ~ ratio, data = tbl_log_reg_sona, family = binomial(link = "logit"))
summary(log_reg_sona)
## 
## Call:
## glm(formula = notice ~ ratio, family = binomial(link = "logit"), 
##     data = tbl_log_reg_sona)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0053  -1.1672   0.6951   0.9812   1.2756  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)
## (Intercept)  -0.6924     1.0666  -0.649    0.516
## ratio         0.5755     0.4983   1.155    0.248
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 24.057  on 17  degrees of freedom
## Residual deviance: 22.537  on 16  degrees of freedom
## AIC: 26.537
## 
## Number of Fisher Scoring iterations: 4
plot_sona <- ggplot(tbl_log_reg_sona, aes(x=ratio, y=notice)) + xlim(0,5) + geom_point() + stat_smooth(method="glm", method.args=list(family="binomial"), se=TRUE, color="#f7a800") + theme_classic((base_size = 15))
suppressMessages(print(plot_sona))

2.5.2 Logistic regression (Dichotomous predictor, dichotomous outcome)

log_reg_sona <- glm(notice ~ style, data = tbl_log_reg_sona, family = binomial)
summary(log_reg_sona)
## 
## Call:
## glm(formula = notice ~ style, family = binomial, data = tbl_log_reg_sona)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4823  -1.3369   0.9005   0.9005   1.4823  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)
## (Intercept)    0.6931     0.5477   1.266    0.206
## stylewholist  -1.3863     1.3416  -1.033    0.301
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 24.057  on 17  degrees of freedom
## Residual deviance: 22.915  on 16  degrees of freedom
## AIC: 26.915
## 
## Number of Fisher Scoring iterations: 4

3 MTurk Subjects

3.1 Read-in datafiles

Read in the individual subject files (saved automatically on the server as csv files).

Get a count of the number of subjects.

nrow(tbl_all_mturk %>% distinct(ID,.keep_all = FALSE))
## [1] 63

3.2 Cognitive Styles

Split up the cognitive styles stimuli nomenclature to task, answer, and number. Filter the two cognitive styles tasks.

tbl_all_cog_style_mturk <- tbl_all_mturk %>%
  separate(stim1,into=c('task', 'answer', 'number')) %>% 
  filter(task == 'matching' | task == 'embedded')
tbl_all_cog_style_mturk = subset(tbl_all_cog_style_mturk, select = -c(ITI,stimFormat,button1,keyboard,key,responseWindow,head,responseType,randomPick,responseOptions,pageBreak,required,responseCode,correct))

3.2.1 Analyze accuracy

In the matching figures task, subjects were instructed to press ‘F’ if the two complex shapes were the same and ‘J’ if the two complex shapes were different. Trials will be labeled 1 for correct responses (‘F’ for same objects and ‘J’ for different objects) and 0 for incorrect responses (‘F’ for different objects and ‘J’ for same objects).

In the embedded figures task, subjects were instructed to press ‘F’ if the simple shape is within the complex shape and ‘J’ if the the simple shape is not within the complex shape. Trials will be labeled 1 for correct responses (‘F’ for simple within complex and ‘J’ for simple not within complex) and 0 for incorrect responses (‘F’ simple not within complex and ‘J’ simple within complex).

tbl_all_cog_style_mturk$acc = "filler"

for (i in 1:length(tbl_all_cog_style_mturk$ID)){
  if (tbl_all_cog_style_mturk$task[i] == "matching"){
    if (tbl_all_cog_style_mturk$answer[i] == "same"){
      if (tbl_all_cog_style_mturk$response[i] == "f"){
        tbl_all_cog_style_mturk$acc[i] = 1
    } else {
        tbl_all_cog_style_mturk$acc[i] = 0
    }
    } else {
      if (tbl_all_cog_style_mturk$response[i] == "j"){
        tbl_all_cog_style_mturk$acc[i] = 1
    } else {
        tbl_all_cog_style_mturk$acc[i] = 0
    }
  }
  }
  if (tbl_all_cog_style_mturk$task[i] == "embedded"){
    if (tbl_all_cog_style_mturk$answer[i] == "yes"){
      if (tbl_all_cog_style_mturk$response[i] == "f"){
        tbl_all_cog_style_mturk$acc[i] = 1
    } else {
        tbl_all_cog_style_mturk$acc[i] = 0
    }
    } else {
      if (tbl_all_cog_style_mturk$response[i] == "j"){
        tbl_all_cog_style_mturk$acc[i] = 1
    } else {
        tbl_all_cog_style_mturk$acc[i] = 0
    }
  }
  }
}

3.2.2 Plot accuracy

tbl_all_cog_style_acc_mturk <- tbl_all_cog_style_mturk %>%
  group_by(ID,task,acc) %>%
  dplyr::summarize(counts = n()) %>%
  spread(acc,counts) %>% 
  mutate(total = rowSums(.[3:4], na.rm = TRUE))
colnames(tbl_all_cog_style_acc_mturk) <- c("ID", "task", "inacc", "acc", "total")
tbl_all_cog_style_acc_mturk[is.na(tbl_all_cog_style_acc_mturk)] <- 0
tbl_all_cog_style_acc_mturk$rate <- tbl_all_cog_style_acc_mturk$acc / tbl_all_cog_style_acc_mturk$total

tbl_all_cog_style_acc_mturk %>%
  ggbarplot("ID", "rate", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), font.xtickslab = 6, ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + rotate_x_text() + geom_hline(yintercept = .5, linetype = 2)

tbl_all_cog_style_acc_mturk %>%
  ggbarplot("task", "rate", add = "mean_se",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + geom_hline(yintercept = .5, linetype = 2)

embedded_chance_mturk <- tbl_all_cog_style_acc_mturk %>% 
  filter(task =="embedded")
embedded_chance_mturk <-t.test(embedded_chance_mturk$rate, mu = .50, alternative="greater")
embedded_chance_mturk
## 
##  One Sample t-test
## 
## data:  embedded_chance_mturk$rate
## t = 15.737, df = 62, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.7837754       Inf
## sample estimates:
## mean of x 
## 0.8174603
matching_chance_mturk <- tbl_all_cog_style_acc_mturk %>% 
  filter(task =="matching")
matching_chance_mturk <-t.test(matching_chance_mturk$rate, mu = .50, alternative="greater")
matching_chance_mturk
## 
##  One Sample t-test
## 
## data:  matching_chance_mturk$rate
## t = 15.215, df = 62, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.7441123       Inf
## sample estimates:
## mean of x 
## 0.7742063
tbl_all_cog_style_acc_mturk %>% 
  with(t.test(rate~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  rate by task
## t = 2.8711, df = 62, p-value = 0.00559
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.01313904 0.07336889
## sample estimates:
## mean of the differences 
##              0.04325397

3.2.3 Remove subjects below chance

tbl_all_cog_style_acc_mturk <- subset(tbl_all_cog_style_acc_mturk, select = c(ID, task, rate))
tbl_all_cog_style_acc_mturk_wide <- tbl_all_cog_style_acc_mturk %>%
  spread(task,rate)

tbl_all_cog_style_acc_mturk <- tbl_all_cog_style_acc_mturk_wide %>%
  filter(embedded > 0.5 & matching > 0.5)

tbl_all_cog_style_acc_mturk <- gather(tbl_all_cog_style_acc_mturk, task, rate, embedded:matching, factor_key=TRUE)

tbl_all_cog_style_acc_mturk %>%
  ggbarplot("ID", "rate", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), font.xtickslab = 6, ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + rotate_x_text() + geom_hline(yintercept = .5, linetype = 2)

tbl_all_cog_style_acc_mturk %>%
  ggbarplot("task", "rate", add = "mean_se",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), ylab = "Accuracy", ylim = c(0, 1), position = position_dodge(0.8)) + geom_hline(yintercept = .5, linetype = 2)

embedded_chance_mturk <- tbl_all_cog_style_acc_mturk %>% 
  filter(task =="embedded")
embedded_chance_mturk <-t.test(embedded_chance_mturk$rate, mu = .50, alternative="greater")
embedded_chance_mturk
## 
##  One Sample t-test
## 
## data:  embedded_chance_mturk$rate
## t = 23.26, df = 55, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.8326973       Inf
## sample estimates:
## mean of x 
## 0.8584821
matching_chance_mturk <- tbl_all_cog_style_acc_mturk %>% 
  filter(task =="matching")
matching_chance_mturk <-t.test(matching_chance_mturk$rate, mu = .50, alternative="greater")
matching_chance_mturk
## 
##  One Sample t-test
## 
## data:  matching_chance_mturk$rate
## t = 19.115, df = 55, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 0.5
## 95 percent confidence interval:
##  0.7778165       Inf
## sample estimates:
## mean of x 
## 0.8044643
tbl_all_cog_style_acc_mturk %>% 
  with(t.test(rate~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  rate by task
## t = 3.3923, df = 55, p-value = 0.00129
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.02210619 0.08592953
## sample estimates:
## mean of the differences 
##              0.05401786

3.2.4 Plot RTs

tbl_all_cog_style_rts_mturk<- tbl_all_cog_style_mturk[(tbl_all_cog_style_mturk$ID %in% tbl_all_cog_style_acc_mturk$ID),] %>% 
  filter(acc == 1)

tbl_all_cog_style_rts_mturk %>%
  ggbarplot("ID", "RT", fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), font.xtickslab = 6, add = "median", position = position_dodge(0.8), ylab = "Median RT (ms)", ylim = c(0,8000)) + rotate_x_text()

tbl_all_cog_style_rts_mturk %>%
  ggbarplot("task", "RT", add = "median",fill = "task", color = "task", palette = c("#0d2240", "#00a8e1"), position = position_dodge(0.8), order = c("embedded", "matching"), ylab = "Median RT (ms)", ylim = c(0,5000))

tbl_all_cog_style_rts_median_mturk <- tbl_all_cog_style_rts_mturk %>%
  group_by(ID,task) %>%
  dplyr::summarize(median_rt = median(RT, na.rm=TRUE))

tbl_all_cog_style_rts_median_mturk %>% 
  with(t.test(median_rt~task,paired=TRUE))
## 
##  Paired t-test
## 
## data:  median_rt by task
## t = -7.1563, df = 55, p-value = 2.091e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1962.355 -1103.734
## sample estimates:
## mean of the differences 
##               -1533.045

3.2.5 Compute cognitive style ratio

The wholist-analytic ratio is calculated by dividing the median response latency to items in the matching figures task (wholist) by the median response latency to items in the embedded figures task (analytic) A ratio of below 1 indicates that an individual responded relatively faster to the matching figure items, corresponding to a wholist profile; a ratio of above 1 indicates that an individual responded relatively faster to the embedded figure items, corresponding to a analytic profile.

tbl_all_cog_style_rts_median_mturk <- tbl_all_cog_style_rts_median_mturk %>% 
  spread(task, median_rt)
tbl_all_cog_style_rts_median_mturk$ratio <- tbl_all_cog_style_rts_median_mturk$matching / tbl_all_cog_style_rts_median_mturk$embedded

tbl_all_cog_style_rts_median_mturk$style = "filler"
for (i in 1:length(tbl_all_cog_style_rts_median_mturk$ID)){
  if (tbl_all_cog_style_rts_median_mturk$ratio[i] > 1){
    tbl_all_cog_style_rts_median_mturk$style[i] = "analytic"
  } else {
    tbl_all_cog_style_rts_median_mturk$style[i] = "wholist"
  }
}

tbl_all_cog_style_rts_median_mturk %>%
  ggbarplot("ID", "ratio", fill = "#f7a800", color = "#f7a800", font.xtickslab = 8, ylim = c(0,6), ylab = "Median wholist-analytic ratio") + rotate_x_text() + geom_hline(yintercept = 1, linetype = 2)

table(tbl_all_cog_style_rts_median_mturk$style)
## 
## analytic  wholist 
##       48        8

3.3 IB performance

tbl_all_mturk <- tbl_all_mturk[(tbl_all_mturk$ID %in% tbl_all_cog_style_rts_median_mturk$ID),] 

tbl_all_IB_mturk <- tbl_all_mturk %>% 
  filter(grepl('Did you notice|item', head))
tbl_all_IB_mturk = subset(tbl_all_IB_mturk, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

3.3.1 Noticers vs. Non-noticers

tbl_all_notice_mturk <- tbl_all_IB_mturk %>% 
  filter(grepl('items', head))
table(tbl_all_notice_mturk$response)
## 
##       No Not sure      Yes 
##       25       19       12

3.3.2 Unexpected event description

tbl_all_event_mturk <- tbl_all_IB_mturk %>% 
  filter(grepl('moved', head))
tbl_all_event_mturk <- cbind.data.frame(tbl_all_event_mturk[1], tbl_all_event_mturk[6])
knitr::kable(tbl_all_event_mturk)
ID response
A3QRZPJT2CT2IK I did not take notice. I was strictly looking for white going across the line.
A1MBEQJXRP50O I did not see any item.
A1P2RQ166VS5BT I didn’t see it. Was concentrated on counting the letters
A2PIFMM4Q2I9ZS I did not see an item
A11TPUPFP2S4MK Not sure
A2CY1TSQ3KKP5Q I did not notice this item
AJ9IY4IHOGB8 t and l move across but + as centre
AXPZAP62ZYWP8 i did not see anything different i was focused on the white shapes
A8028AFBBS29G no
A3CFF2BT7P8FL4 +
A3180VXVP8MOIH I cannot recall
A37OUZOGQKGMW0 I was not sure if they were in the last task or not.
A2WJMGV0HKQG3Z x
A3FQDPUAXJB0BS I think it was the first one (the +). It moved from right to left on the horizontal line.
AHKYVHP6591H8 Did not remember the item.
AXMPSUNKUBEIL I didn’t notice any other letter or symbol.
A2KCNQ0T27VM2S it moved top to bottom,bottom to up
A36QBKROJ4J9EJ Did not see the objects.
A1W2L6BM7VQCXO I am just T and X
A3R5OJR60C6004 I noticed a “t” but was simply focused on white objects and not any specific detail
A34NDXO56MBC3D The + and it was static
A1J19UOHNI0UOC I honestly don’t recall seeing any of those 3 objects.
A1F1BIPJR11LSR Not sure.
A1PRG2OSEWHYNF the letter L moved here and there
A1V1JNPU0KOA3X I did not notice
A2OVX9UW5WANQE not sure
A11Q8U6QTT8KGF +, it seemed to pulse around the screen
A10JXOU89D5RXR did not notice that
A1LA6CIGBNDOH9 I didn’t notice it.
A1TRWC1E9GI836 +
A1F1TBDHPYAAXT T and L
A1D9ZWU1M46SAF I did not notice any of those I was focused on the 4 white letters
A1GKD3NG1NNHRP don’t know
A1VR1XQEQQXYUE n/a
A12FTSX85NQ8N9 Yeah I think I say the cross move off to the left of the screen
A2Y0WNHMT4PZ4C I did not see it but I would guess it bounced around the screen?
A3KP8KFGG6734Q x
A29AKJXQ248KNK The x moved left to right
A2O2Y99RA9GFUJ i just watched the white ones move around
A1WS9UHL45VZ0X I guess I saw X? I think it moved similarly to the other shapes.
A30Y3H3UJ9QKWV I did not see them.
A1DZMZTXWOM9MR It was the cross shape and it moved from the right portion of the scene, towards the lead side.
A3UDUHUVFKD833 I am not sure
A1SISJL5ST2PWH It was the cross and it moved from right to left.
A1KS9LITOVPAT8 +
AZ69TBTDH7AZS n/a
A2ZRL1ZWWXJ0L7 The plus sign moved across the center line.
A22LZ62E0UC4VL I don’t know!
A2VB8KX3XUA6WU Did not notice. I wasn’t paying attention to what the objects were, only to their color.
A7N3J27F3IL6M I did not see a foreign item.
A16R03XE6GSNOB exw
ACBNJC661QT03 T and L
A2C73Y1COWCA51 i only t shapes move
A1IFF4KV23FGHJ I didn’t notice any particular shape, I just focused on the color and the motion in tangent with the center line.
A21D9YDJU8K2QI I am not sure but it moved up and down
A3R3FXOXBUDG1X x

3.4 Post IB questions

3.4.1 Expecting an unexpected event

tbl_all_expecting_mturk <- tbl_all_mturk %>% 
  filter(grepl('Before', head))
tbl_all_expecting_mturk = subset(tbl_all_expecting_mturk, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

table(tbl_all_expecting_mturk$response)
## 
##  No Yes 
##  50   6

3.4.2 Familiarity with IB experiments

tbl_all_familiarity_mturk <- tbl_all_mturk %>% 
  filter(grepl('gorilla', head))
tbl_all_familiarity_mturk = subset(tbl_all_familiarity_mturk, select = -c(stim1,ITI,stimFormat,button1,keyboard,key,responseWindow,randomBlock,responseType,randomPick,responseOptions,pageBreak,required,ITI_ms,ITI_f,ITI_fDuration,responseCode))

table(tbl_all_familiarity_mturk$response)
## 
##  No Yes 
##  41  15

3.5 Cognitive style ratio predicting IB

3.5.1 Logistic regression (Continuous predictor, dichotomous outcome)

tbl_log_reg_mturk <- merge(tbl_all_cog_style_rts_median_mturk, tbl_all_notice_mturk, by = "ID")
tbl_log_reg_mturk = subset(tbl_log_reg_mturk, select = -c(rowNo,type,head,timestamp,RT,correct))
tbl_log_reg_mturk[tbl_log_reg_mturk == "Yes"] <- 1
tbl_log_reg_mturk[tbl_log_reg_mturk == "No"] <- 0
tbl_log_reg_mturk[tbl_log_reg_mturk == "Not sure"] <- 0
names(tbl_log_reg_mturk)[names(tbl_log_reg_mturk)=="response"] <- "notice"
tbl_log_reg_mturk$notice <- as.numeric(tbl_log_reg_mturk$notice)

log_reg_mturk <- glm(notice ~ ratio, data = tbl_log_reg_mturk, family = binomial(link = "logit"))
summary(log_reg_mturk)
## 
## Call:
## glm(formula = notice ~ ratio, family = binomial(link = "logit"), 
##     data = tbl_log_reg_mturk)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -1.72122  -0.42278  -0.09136  -0.00146   2.01676  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)   
## (Intercept)    5.550      2.015   2.754  0.00588 **
## ratio         -5.012      1.650  -3.038  0.00238 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 58.193  on 55  degrees of freedom
## Residual deviance: 32.680  on 54  degrees of freedom
## AIC: 36.68
## 
## Number of Fisher Scoring iterations: 7
plot_mturk <- ggplot(tbl_log_reg_mturk, aes(x=ratio, y=notice)) + xlim(0,6) + geom_point() + stat_smooth(method="glm", method.args=list(family="binomial"), se=TRUE, color="#f7a800") + theme_classic((base_size = 15))
suppressMessages(print(plot_mturk))

3.5.2 Logistic regression (Dichotomous predictor, dichotomous outcome)

log_reg_mturk <- glm(notice ~ style, data = tbl_log_reg_mturk, family = binomial)
summary(log_reg_mturk)
## 
## Call:
## glm(formula = notice ~ style, family = binomial, data = tbl_log_reg_mturk)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4006  -0.5615  -0.5615  -0.5615   1.9623  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)    -1.768      0.409  -4.322 1.54e-05 ***
## stylewholist    2.279      0.837   2.722  0.00649 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 58.193  on 55  degrees of freedom
## Residual deviance: 50.465  on 54  degrees of freedom
## AIC: 54.465
## 
## Number of Fisher Scoring iterations: 4