One of the research questions is the paired comparison of the ERPs under the two instructions (TBF/TBR). A raw yet popular method consists in averaging the ERPs within time intervals in a partition of the whole range of observations. Let us say here that the whole interval is split into 10 sub-intervals of 100 ms. Then, within each sub-interval, paired t-tests are applied on the averaged ERPs. This can be done using the function erpavetest. As the other testing functions in the ERP package, erpavetest is designed to compare linear models using F-tests, here the null model with just the subject effect and the non-null model with the subject and instruction effects:

mod0 = model.matrix(~Subject,data=erpcz)
mod1 = model.matrix(~Subject+Instruction,data=erpcz)
tests = erpavetest(erpcz[,1:251],design=mod1,design0=mod0,nintervals=10)

Note that the argument ‘nintervals’ defines the splitting of the whole intervals by giving the desired number of sub-intervals.

The results are stored into the object tests, which components

- ‘signal’ contains the estimated coefficients for the instruction effect;
- ‘significant’ contains the indices of the significant timepoints;
- ‘breaks’ contains the nodes of the time partition used for testing.

The following commands use these components to plot the results of the multiple testing procedure:

frames = seq(0,1001,4)
plot(frames,tests$signal,type="l",xlab="Time (ms)",
ylab="Difference ERP curves")
points(frames[tests$significant],rep(0,length(tests$significant)),
pch=16,col="blue")
abline(v=frames[tests$breaks],lty=2,col="darkgray")
title("Paired comparison at electrode CZ")

This generates the following plot:

### Like this:

Like Loading...