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

Descriptive statistics

Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in longer RTs (836 vs. 689 ms)

mean_RT_trial <- data %>%
  group_by(TaskType) %>%
  summarize(mean_RT = mean(RT, na.rm = TRUE))

My results showed that TaskType 1 had a meanRT of 863.4404, whereas TaskType 2 had a meanRT of 699.

Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in […] lower accuracy rates (79% vs. 92%)

accuracy_1 <- data %>%
  group_by(TaskType) %>%
  summarize(correct_response_proportion = sum(RespCorr == TRUE) / n())

My results showed that TaskType 1 had an accuracy of 85% and TaskType 2 had an accuracy of 92%

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
mean_RT_2 <- data %>%
  group_by(TrialType) %>%
  summarize(mean_RT = mean(RT, na.rm = TRUE))

mean_RT_2 <- mean_RT_2[-1,]

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

accuracy_2 <- data %>%
  group_by(TrialType) %>%
  summarize(correct_response_proportion = sum(RespCorr == TRUE) / n())


accuracy_2 <- accuracy_2[-1,]

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.

# mean RT-predictive cues were found above. Here, the mean difference is: 
mean_diff <- abs(mean_RT_2[2, "mean_RT"] -  mean_RT_trial[2, "mean_RT"])
two_tailed_paired <- t.test(mean_RT_trial$mean_RT, mean_RT_2$mean_RT, paired = TRUE, alternative = "two.sided")

two_tailed_paired
## 
##  Paired t-test
## 
## data:  mean_RT_trial$mean_RT and mean_RT_2$mean_RT
## t = -0.1942, df = 1, p-value = 0.8779
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -2121.057  2057.196
## sample estimates:
## mean difference 
##       -31.93049

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.

#this was calculated earlier when finding the error rate across tasks. 

Step 5: Reflection

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

First, I was unable to reproduce the same exact numbers for the first part of the analysis. I was unable to produce even close estimates of the second part of the analysis where the t-test was required.

How difficult was it to reproduce your results?

It was quite difficult to reproduce the results – I was even unable to get the accurate results for something as simple as finding the meanRT time. The two-tailed test parameters were also quite difficult to find.

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

This was quite difficult because the column names were ambiguous and there was no key associated with the columns. In the Group A projects, each column came with a key that showed the meaning of 0 and 1. This was not the case here. The column names were also not labeled in a way that differentiated them clearly. For example, I didn’t understand the difference between trial and task type. Also, there were two columns named CorrResp and Respcorr – I did not understand the difference between these two columns.