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.

Methods summary:

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.


Target outcomes:

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.


Step 1: Load packages

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)

Step 2: Load data

# 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)
  }
}

Step 3: Tidy data

Each row is an observation. The data is already in tidy format.

Step 4: Run analysis

Pre-processing

M goes with switch, T with repeat, O unpredictable.

data_clean <- data %>% select(id, Prime, RT, swt, stay, RespCorr) %>% 
  filter(!is.na(swt) | !is.na(stay)) %>% 
  mutate(type = ifelse(!is.na(swt), "switch", "repeat"),
         is.correct=ifelse(RespCorr=="TRUE", 1,0))

Descriptive statistics

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
svr <- data_clean %>% group_by(type) %>% 
  summarize(med_RT=median(RT),
            mean_RT=mean(RT))

kable(svr)
type med_RT mean_RT
repeat 665.0625 730.9531
switch 812.9375 895.6084

Looks like maybe there’s some exclusions going on? These are correct direction, but higher than what was reported, but I don’t see exclusions reported in the paper. The paper mentions using median rather than mean, but that also isn’t it. I also tried averaging by-participant medians, but that’s yet a different value.

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
mean_corr <- data_clean %>% group_by(type) %>% 
  summarize(pct_correct=mean(is.correct))

kable(mean_corr)
type pct_correct
repeat 0.9137196
switch 0.7919738

Not quite right, but close.

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; … )

prime <- data_clean %>% 
  filter(type=="switch") %>% 
  group_by(type, Prime) %>% 
  summarize(RT=mean(RT))

kable(prime)
type Prime RT
switch 2 849.8008
switch 8 777.2810
switch M 937.2244
switch O 933.0889

Not sure what’s up with numbers as the switch cues (paper seems to mention O,M,T, but not numbers). Also, we still have the larger numbers than they did, could be from same exclusion.

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%)

prime <- data_clean %>% 
  filter(type=="switch") %>% 
  group_by(type, Prime) %>% 
  summarize(pct_corr=mean(is.correct))

kable(prime)
type Prime pct_corr
switch 2 0.7350000
switch 8 0.7512690
switch M 0.8307292
switch O 0.8022727

Still not sure what’s going on with the different primes.

Inferential statistics

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.

data_test <- data_clean %>% filter(Prime %in% c("O", "M")) %>% 
  filter(type=="switch") %>%
  group_by(id, Prime) %>% 
  summarize(med_rt=median(RT)) %>% 
  pivot_wider(names_from=Prime,values_from=med_rt)

t.test(data_test$M, data_test$O)
## 
##  Welch Two Sample t-test
## 
## data:  data_test$M and data_test$O
## t = -0.41876, df = 25.884, p-value = 0.6788
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -154.2916  102.0751
## sample estimates:
## mean of x mean of y 
##  836.0413  862.1496

No idea what’s going on.

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.

data_test <- data_clean %>% filter(Prime %in% c("O", "M")) %>% 
  filter(type=="switch") %>%
  group_by(id, Prime) %>% 
  summarize(pct_corr=mean(is.correct)) %>% 
  pivot_wider(names_from=Prime,values_from=pct_corr)

t.test(data_test$M, data_test$O)
## 
##  Welch Two Sample t-test
## 
## data:  data_test$M and data_test$O
## t = 0.59763, df = 25.093, p-value = 0.5554
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.06634625  0.12060544
## sample estimates:
## mean of x mean of y 
## 0.8301919 0.8030623

Still no idea what they’re doing.

Step 5: Reflection

Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?

Unable to get any of them to reproduce (not being able to get the more basic things to reproduce and inability to know where some of the data is coming from makes me dubious that given the right choices I would be able to).

How difficult was it to reproduce your results?

Very difficult in that I couldn’t. Still don’t know what’s up with the 2,4,8 options for primes (which aren’t mentioned in the paper). Paper also mentions some exclusions which maybe should have been applied?

What aspects made it difficult? What aspects made it easy?

I want a data dictionary, since the paper doesn’t lay out some of the values in the data. Also their mention of median in the paper makes me unsure how even their central tendency numbers are calculated (mean?, median?, by participant or aggregated?).