This exercise is based on data from a PhD student in cognitive psychology. In his work, this student collects response times (RT) to two simultaneous tasks, and then he has to analyse the response times.
The inter-response interval (IRI) is defined as the time difference between \(t_3\) and \(t_2\), thus \(IRI=SOA+RT2-RT1\). Negatives IRI therefore mean that the response to S2 is emitted before the response to S1.
For theoretical reasons, one can consider that if \(SOA=1500\) ms, both stimulis are answered independently. One can thus use the RT1 and RT2 values for SOA=1500 ms to estimate the IRI in the case of independent responses to the stimuli.
Download the datafiles archive and unzip it, then create a R project in this folder in Rstudio.
Load the tidyverse
and patchwork
packages:
Load the .csv file in the Data
folder and save it
into raw_data
. Look into the help of read_csv()
to help
you get rid of the error.
Using successive pipe operations, we will now
create a dataclean
table from raw_data
, where
we:
raw_data
so that
Procedure[Trial]
is only equal to
"EssaisDT"
IRI
containing
SOAdur + S2Visuel.RT - S1Audio.RT
S1Audio.RT
is smaller or equal to 2500 and larger or
equal to 100S2Visuel.RT
is smaller or equal to 2500 and larger or
equal to 100S1Audio.ACC
, S1response.ACC
and
S2Visuel.ACC
are equal to 1Let’s compute the simulated values in the case the responses to
the stimuli are independent, i.e. using SOA=1500ms, and save it
into a tibble called IRI_sim
. Using successive pipe
operations and starting from dataclean
:
SOAdur
is equal to
1500SOAdur
and IRI
columnsIRI_sim_xx
, where xx
=15, 65 or 250 and
IRI_sim_xx = xx + S2Visuel.RT - S1Audio.RT
.pivot_longer()
and
the options
names_prefix = "IRI_sim_", names_to = "SOAdur", values_to = "IRI_sim"
,
pivot the columns containing "IRI_sim_"
into a long table
(you need to add the option to select the corresponding columns).We want now to get the averaged IRI
per subject and
per SOA, and its standard deviation. Using group_by()
and summarise()
, store
the mean and standard deviation of IRI
in a table called
stats_obs
, starting from dataclean
. It should
look like this:
## # A tibble: 24 × 4
## # Groups: Subject [6]
## Subject SOAdur mean sd
## <dbl> <dbl> <dbl> <dbl>
## 1 1 15 -64.8 291.
## 2 1 65 20.8 297.
## 3 1 250 218. 217.
## 4 1 1500 1019. 228.
## 5 2 15 -159. 193.
## 6 2 65 -156. 236.
## 7 2 250 4.42 191.
## 8 2 1500 1184. 198.
## 9 3 15 -289. 207.
## 10 3 65 -251. 262.
## # … with 14 more rows
## # A tibble: 18 × 4
## # Groups: Subject [6]
## Subject SOAdur mean sd
## <dbl> <chr> <dbl> <dbl>
## 1 1 15 -466. 228.
## 2 1 250 -231. 228.
## 3 1 65 -416. 228.
## 4 2 15 -301. 198.
## 5 2 250 -65.9 198.
## 6 2 65 -251. 198.
## 7 3 15 -99.0 157.
## 8 3 250 136. 157.
## 9 3 65 -49.0 157.
## 10 4 15 -168. 214.
## 11 4 250 66.9 214.
## 12 4 65 -118. 214.
## 13 5 15 -367. 249.
## 14 5 250 -132. 249.
## 15 5 65 -317. 249.
## 16 6 15 -313. 161.
## 17 6 250 -77.9 161.
## 18 6 65 -263. 161.
IRI
column using ggplot2
.
ggplot
using the dataclean
datasetx = IRI
geom_histogram()
,
with a fill color depending on SOAdur
Subject
column using facet_wrap()
geom_vline()
.
The data for these lines are stored in the stats_obs
dataset.