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.
# need col vars: Prime (cue type), RT, RespCorr (accuracy), TrialType (repeat/stay = 1, switch=2) (from Experiment 1/Codebook.xls)
# remove unnecessary cols
d <- data |>
select(!contains("...")) |>
select(-c("stay", "swt", "PrimeVisible"))
# remove rows with TrialType == 0 ... ????
d <- d |>
filter(TrialType != 0)
Performance on switch trials, relative to repeat trials, incurred a switch cost that was evident in longer RTs (836 vs. 689 ms)
# old attempt (not within subj)
#d |>
# group_by(TrialType) |>
# summarize(mean = mean(RT))
# reproduce the above results here
d_subjmeans <- d |>
# need within-subj RTs
group_by(TrialType, id) |>
summarize(meanRT = mean(RT))
d_subjmeans |>
# now calculate withinsubj group means
group_by(TrialType) |>
summarize(mean = mean(meanRT))
## # A tibble: 2 × 2
## TrialType mean
## <dbl> <dbl>
## 1 1 731.
## 2 2 897.
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
d |>
group_by(TrialType) |>
summarize(mean = mean(RespCorr))
## # A tibble: 2 × 2
## TrialType mean
## <dbl> <dbl>
## 1 1 0.914
## 2 2 0.792
# this seems right in switch condition, but repeat accuracy is slightly off...
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
d |>
filter(TrialType == 2) |>
filter(Prime %in% c('M', 'O')) |>
# need within-subj means
group_by(id, Prime) |>
summarize(meanRT = mean(RT)) |>
ungroup() |> # because it's not technically a table... grrrr
group_by(Prime) |>
summarize(mean = mean(meanRT)) # hard to keep track of which is function, which is label
## # A tibble: 2 × 2
## Prime mean
## <chr> <dbl>
## 1 M 935.
## 2 O 940.
# something still wrong....
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
# need within-subj error rates
d |>
filter(TrialType == 2) |>
filter(Prime %in% c('M', 'O')) |>
group_by(Prime) |>
summarize(mean = mean(RespCorr))
## # A tibble: 2 × 2
## Prime mean
## <chr> <dbl>
## 1 M 0.831
## 2 O 0.802
# welp...
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
#d |>
# filter(TrialType == 2) |>
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
# at this point, have spent 3 hours...
Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?
No, I have not been able to replicate even descriptive statistics
How difficult was it to reproduce your results?
difficult, since i rewrote descriptive statistics for within-subj means, but still did not understand what was going on
What aspects made it difficult? What aspects made it easy?
ANSWER HERE