## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## âś” ggplot2 3.3.6     âś” purrr   0.3.5
## âś” tibble  3.1.8     âś” dplyr   1.0.9
## âś” tidyr   1.2.0     âś” stringr 1.5.0
## âś” readr   2.1.2     âś” forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## âś– dplyr::filter() masks stats::filter()
## âś– dplyr::lag()    masks stats::lag()
## here() starts at /home/vboyce/Research/mia23
data_loc <- "data_1"
images <- "images_1"

sternberg <- list.files(path=here(data_loc), pattern=".*sternberg.*csv") |> 
  map_df(~read_csv(here(data_loc,.))) |> 
  filter(!is.na(response_type)) |> 
  select(match_type, response_type, correct, rt, subject_id,trial_index) |> 
  unique() |> 
  mutate(rt=as.numeric(rt))


nback <- list.files(path=here(data_loc), pattern=".*nback.*csv") |> 
  map_df(~read_csv(here(data_loc,.))) |> 
  filter(!is.na(response_type)) |> 
  filter(exclude_trial==F) |> 
  select(phase, match_type, response_type, correct, rt, subject_id, trial_index) |> 
  unique() |> 
  mutate(rt=as.numeric(rt))

Sternberg task

This analysis is based on responses from 131 students.

Accuracy

Overall, the accuracy on the sternberg task was very high!

sternberg |> group_by(subject_id) |> 
  mutate(is.correct=as.numeric(correct)) |> 
  summarize(mean_correct=mean(is.correct)) |> 
  ggplot(aes(x="Sternberg task", y=mean_correct))+geom_jitter(width=.2, height=0.05, alpha=.1)+
  stat_summary(fun.data = "mean_cl_boot", color="red")+
  labs(y="Percent correct", x="")

ggsave(here(images,"sternberg_acc.png"))

Speed

sternberg |> mutate(correct=ifelse(correct,"correct", "incorrect")) |> 
  ggplot(aes(x=rt, fill=correct))+
  geom_histogram()+facet_wrap(.~correct)+scale_fill_solarized()+
  theme(legend.position = "none")+
  labs(x="Reaction Time")

ggsave(here(images,"sternberg_rts.png"), dev="png")
sternberg |> mutate(correct=ifelse(correct,"correct", "incorrect")) |> 
  ggplot(aes(x=correct, y=rt))+geom_jitter(width=.2, height=0, alpha=.02)+
  stat_summary(fun.data = "mean_cl_boot", color="red", size=1)+
  labs(y="Response time in ms", x="")

The average reaction time was roughly 1 second for both correct and incorrect answers. As is common with reaction time data, the distribution of times is roughly log-normal.

N-back

This analysis is based on responses from 129 students.

Accuracy

There were a number of non-responses, potentially due to not understanding the task. If we treat non-responses as false, this is what accuracy looks like.

# counts non response as false
nback |> group_by(phase, subject_id) |> 
  mutate(is.correct=as.numeric(correct)) |> 
  summarize(mean_correct=mean(is.correct)) |> 
  ggplot(aes(x=phase, y=mean_correct))+geom_jitter(width=.2, height=0.05, alpha=.1)+
  stat_summary(aes(color=phase),fun.data = "mean_cl_boot", size=1)+
  labs(y="Percent correct", x="")+
  theme(legend.position = "none")

If we instead exclude the non-responses, the accuracy instead looks like this.

# excluding non responses
nback |> filter(response_type!="NO_RESPONSE") |> 
  group_by(phase, subject_id) |> 
  mutate(is.correct=as.numeric(correct)) |> 
  summarize(mean_correct=mean(is.correct)) |> 
  ggplot(aes(x=phase, y=mean_correct))+geom_jitter(width=.2, height=0, alpha=.1)+
  stat_summary(aes(color=phase),fun.data = "mean_cl_boot", size=1)+
  labs(y="Percent correct", x="")+
  theme(legend.position = "none")

ggsave(here(images,"nback_acc.png"), dev="png")

In either case, we can see that accuracy slowly declines as the N increases.

Speed

nback |> filter(response_type!="NO_RESPONSE") |> 
mutate(correct=ifelse(correct,"correct", "incorrect")) |> 
  ggplot(aes(x=rt, fill=phase))+
  geom_histogram()+facet_grid(.~phase)+scale_fill_solarized()+
  theme(legend.position = "none")+
  labs(x="Reaction Time")

ggsave(here(images,"nback_rt.png"), dev="png")

Again, we can see log-normal distributions of reaction times.

nback|> mutate(correct=ifelse(correct,"correct", "incorrect")) |> 
  ggplot(aes(x=correct, y=rt, color=phase))+#geom_jitter(width=.2, height=0, alpha=.007, color="black")+
  stat_summary(fun.data = "mean_cl_boot", size=.5)+ facet_grid(.~phase)+
  coord_cartesian(ylim=c(800,1200))+
  labs(y="Response time in ms", x="")+theme(legend.position = "none")

ggsave(here(images,"nback_rt2.png"), dev="png")

The speed of 1-back is noticeable faster than that of 2,3, or 4 back, but there isn’t much difference in speed between 2, 3, or 4 back. Incorrect and correct answers are about the same speed.