I previously replicated some simulations from a journal article by Ratcliff (1993) 1. These sims demonstrate that transformations such as taking inverse RTs typically improve power to detect RT differences across conditions. The problem is that the mean alone is a poor estimate of the central tendency of the underlying RT distribution, particularly in the presence of outliers - see the previous post for details.
Reaction times are a very common outcome measure in psychological science. Frequently, people use the mean to summarise reaction time distributions and compares means across conditions using ANOVAs. For example, in a typical experiment, researchers might record reaction times to familiar and unfamiliar faces, and look for differences in mean reaction time across these two types of stimuli.
An issue with this is that reaction time distributions are skewed: there are many more short values than long values, so their distribution has a long right tail.
In an earlier post I took a look at visualizing ERPs from two conditions at a single electrode. This time I’m going to look at three conditions. As in the previous post, I’ll assume a basic familiarity with ERPs.
First I’ll load in the full dataset, which contains ERPs for all conditions for all subjects, and whip it into shape.
library(ggplot2) library(tidyverse) library(afex) library(Rmisc) library(magrittr) levCatGAall <- read_csv( "https://raw.githubusercontent.com/craddm/ExploringERPs/master/levCatGAall.csv", col_names = c("Object.
Shiny app updated! In my last post unleashed the Shiny app I’d knocked up in a few hours to do some basic display of different confidence interval types and difference waves. I’ve been hacking away at it on and off and I’ve now added some exciting new features!
You can now try loading up your own data. You’ll need a .csv file with the following structure:
No header Comma-separated values Each row should be one time-point, one subject, columns should be “condition1”, “condition2”, “Time”, “Subject” Here’s the first few lines of the example data I include (note this is already after import, so it’s stripped the commas between values).
Shiny app In an unusual fit of enthusiasm, I decided to have to go at writing a little app in Shiny, a simple programming framework to make web-based apps using R. So, as usual, all programmed using RStudio, the devs who also make Shiny and various fantastic R packages such as dplyr and ggplot2.
It turned out to be pretty simple. I’m planning to add various additional functions as I get time to work on my blog posts, like allowing people to use their own data, for example.
As I mentioned in a previous post, between-subject confidence intervals/standard errors are not necessarily all that useful when your data is within-subjects. What you’re interested in is the not really the between-subject variability but the variability of the differences between your conditions within subjects. I’m going to use here the command summarySEwithin from the package Rmisc. This removes between-subject variability for within-subject variables, returning corrected standard deviations, standard errors, and confidence intervals.
Running statistical tests using “purrr” Something which puzzled me for a while was how to efficiently perform running (i.e. timepoint-by-timepoint) statistical tests on ERP/EEG in R. That was solved for me when I discovered the purrr package, another of ggplot2 author Hadley Wickham’s projects. Using the split command, you can easily split a data frame into multiple frames by one of its variables. In the EEG/ERP case, that means I can easily split the data into separate data frames for each timepoint and run my test of choice on each timepoint independently using the map command.
ERP visualization is harder than people think. Often people take the path of least resistance, plotting grand average ERP data as simple traces representing condition means, with no information regarding variability around these means. There are a couple of variations on this simple theme which show regions of significance, but it’s extremely rare to show anything else. A new editorial letter by Rousselet, Foxe, and Bolam in the European Journal of Neuroscience offers some useful guidelines, and Ana Todorovic’s recent post on adding scatterplots to time-series data is also great.