For this exercise, please try to reproduce the results from Experiment 1 of the associated paper (Farooqui & Manly, 2015). The PDF of the paper is included in the same folder as this Rmd file.
Participants (N=21) completed a series of trials that required them to switch or stay from one task to the other. One task was to choose the larger value of the two values if surrounded by a green box. The other task was to choose the value with the larger font if surrounded by a blue box. Subliminal cues followed by a mask were presented before each trial. Cues included “O” (non-predictive cue), “M” (switch predictive cue), and “T” (repeat predictive cue). Reaction times and performance accuracy were measured.
Below is the specific result you will attempt to reproduce (quoted directly from the results section of Experiment 1):
Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in longer RTs (836 vs. 689 ms) and lower accuracy rates (79% vs. 92%). If participants were able to learn the predictive value of the cue that preceded only switch trials and could instantiate relevant anticipatory control in response to it, the performance on switch trials preceded by this cue would be better than on switch trials preceded by the nonpredictive cue. This was indeed the case (mean RT-predictive cue: 819 ms; nonpredictive cue: 871 ms; mean difference = 52 ms, 95% confidence interval, or CI = [19.5, 84.4]), two-tailed paired t(20) = 3.34, p < .01. However, error rates did not differ across these two groups of switch trials (predictive cue: 78.9%; nonpredictive cue: 78.8%), p = .8.
library(tidyverse) # for data munging
library(knitr) # for kable table formating
library(haven) # import and export 'SPSS', 'Stata' and 'SAS' Files
library(readxl) # import excel files
# #optional packages:
# library(broom)
# This reads all the participants data (each is in a seperate xls file) in and combines them into one dataframe
# Each xls has 250 rows, the rest is their calculations using excel, which we don't want in the data
files <- dir('data/Experiment 1')
data <- data.frame()
id <- 1
for (file in files){
if(file != 'Codebook.xls'){
temp_data <- read_xls(file.path('data/Experiment 1', file))
temp_data$id <- id
id <- id + 1
temp_data <- temp_data[1:250, ]
data <- rbind(data, temp_data)
}
}
Each row is an observation. The data is already in tidy format.
df <- data %>%
# remove unnecessary observations
filter(
TrialType %in% c(1, 2),
Prime %in% c('O', 'M', 'T')) %>%
mutate(TrialType = ifelse(TrialType == 1, "repeat", "switch")) %>%
# aggregate observed variables to user level
group_by(TrialType, Prime, id) %>%
summarize(
RT = mean(RT, na.rm = T),
acc = mean(RespCorr, na.rm = T))
Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in longer RTs (836 vs. 689 ms)
# reproduce the above results here
df %>%
group_by(TrialType) %>%
summarise(mean_RT = mean(RT, na.rm=T))
## # A tibble: 2 × 2
## TrialType mean_RT
## <chr> <dbl>
## 1 repeat 758.
## 2 switch 938.
Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in […] lower accuracy rates (79% vs. 92%)
# reproduce the above results here
df %>%
group_by(TrialType) %>%
summarise(accuracy = mean(acc, na.rm=T))
## # A tibble: 2 × 2
## TrialType accuracy
## <chr> <dbl>
## 1 repeat 0.921
## 2 switch 0.817
Now you will analyze Predictive Switch Cues vs Non-predictive Switch Cues. Let’s start with reaction time.
This was indeed the case (mean RT-predictive cue: 819 ms; nonpredictive cue: 871 ms; … )
# reproduce the above results here
df %>%
filter(TrialType == "switch") %>%
group_by(Prime) %>%
summarise(mean_RT = mean(RT, na.rm=T))
## # A tibble: 2 × 2
## Prime mean_RT
## <chr> <dbl>
## 1 M 935.
## 2 O 940.
Next you will try to reproduce error rates for Switch Predictive Cues vs Switch Non-predictive Cues.
However, error rates did not differ across these two groups of switch trials (predictive cue: 78.9%; nonpredictive cue: 78.8%)
# reproduce the above results here
df %>%
filter(TrialType == "switch") %>%
group_by(Prime) %>%
summarise(accuracy = mean(acc, na.rm=T))
## # A tibble: 2 × 2
## Prime accuracy
## <chr> <dbl>
## 1 M 0.830
## 2 O 0.803
The first claim is that in switch trials, predictive cues lead to statistically significant faster reaction times than nonpredictive cues.
… the performance on switch trials preceded by this cue would be better than on switch trials preceded by the nonpredictive cue. This was indeed the case (mean RT-predictive cue: 819 ms; nonpredictive cue: 871 ms; mean difference = 52 ms, 95% confidence interval, or CI = [19.5, 84.4]), two-tailed paired t(20) = 3.34, p < .01.
# reproduce the above results here
switch <- df %>% filter(TrialType == "switch")
predictive <- switch %>%
filter(Prime == "M") %>%
select(RT, acc)
nonpredictive <- switch %>%
filter(Prime == "O") %>%
select(RT, acc)
difference <- mean(predictive$RT, na.rm=T) - mean(nonpredictive$RT, na.rm=T)
paste0("Difference: ", difference)
## [1] "Difference: -4.82097307672143"
t.test(
predictive$RT,
nonpredictive$RT,
paired = TRUE,
alternative = "two.sided")
##
## Paired t-test
##
## data: predictive$RT and nonpredictive$RT
## t = -0.12959, df = 13, p-value = 0.8989
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -85.19284 75.55089
## sample estimates:
## mean difference
## -4.820973
Next, test the second claim.
However, error rates did not differ across these two groups of switch trials (predictive cue: 78.9%; nonpredictive cue: 78.8%), p = .8.
# reproduce the above results here
t.test(
predictive$acc,
nonpredictive$acc,
paired = TRUE,
alternative = "two.sided")
##
## Paired t-test
##
## data: predictive$acc and nonpredictive$acc
## t = 1.3861, df = 13, p-value = 0.189
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -0.01515368 0.06941287
## sample estimates:
## mean difference
## 0.0271296
Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?
I wasn’t able to reproduce the effect sizes and the significance, but my results are in the same direction as the original paper.
How difficult was it to reproduce your results?
It was more difficult in comparison to the paper from Group A mainly because of lack of information in the methods section.
What aspects made it difficult? What aspects made it easy?
I found it difficult to reproduce the results mainly because I wasn’t sure about the data processing decisions the original paper followed (even though I used the codebook in
data/Experiment1/Codebook.xls)