library(ez)
library(ggplot2)
library(knitr)
library(ggplot2)
library(gridExtra)
library(plyr)
sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: macOS Sierra 10.12.2
##
## locale:
## [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] plyr_1.8.4 gridExtra_2.2.1 knitr_1.15.1 ggplot2_2.2.1
## [5] ez_4.4-0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.8 nloptr_1.0.4 tools_3.3.2
## [4] digest_0.6.11 lme4_1.1-12 evaluate_0.10
## [7] tibble_1.2 nlme_3.1-128 gtable_0.2.0
## [10] lattice_0.20-34 mgcv_1.8-15 Matrix_1.2-7.1
## [13] yaml_2.1.14 parallel_3.3.2 SparseM_1.74
## [16] stringr_1.1.0 MatrixModels_0.4-1 rprojroot_1.1
## [19] grid_3.3.2 nnet_7.3-12 rmarkdown_1.3
## [22] minqa_1.2.4 reshape2_1.4.2 car_2.1-4
## [25] magrittr_1.5 backports_1.0.4 scales_0.4.1
## [28] htmltools_0.3.5 MASS_7.3-45 splines_3.3.2
## [31] assertthat_0.1 pbkrtest_0.4-6 colorspace_1.3-2
## [34] quantreg_5.29 stringi_1.1.2 lazyeval_0.2.0
## [37] munsell_0.4.3
Global field power
Read in the GFPs dataframe.
GFPs <- read.csv("output/data/GFPs.csv", stringsAsFactors=TRUE)
str(GFPs)
## 'data.frame': 24570 obs. of 6 variables:
## $ X : int 1 2 3 4 5 6 7 8 9 10 ...
## $ time : int -100 -96 -92 -88 -84 -80 -76 -72 -68 -64 ...
## $ Response : Factor w/ 13 levels "Offset","Onset",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ Amplitude: num 8.53 7.66 7.23 6.76 6.62 ...
## $ SubNum : Factor w/ 15 levels "S019","S392",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Paradigm : Factor w/ 2 levels "ACC","MMF": 1 1 1 1 1 1 1 1 1 1 ...
Define the GFP_Plot function. This plots the global field power for a specified response, taking as input the GFPs dataframe. It plots the GFP for each individual participant and overlays the grand mean (average across participants).
GFP_Plot <- function (Response, Title="") {
require(plyr)
require(ggplot2)
IndGFPs <- GFPs[(GFPs$Response==Response),]
IndGFPs$X <- NULL
GM_GFP <- ddply(IndGFPs, .(Paradigm, Response, time), summarize, Amplitude = mean(Amplitude))
GM_GFP$SubNum <- "ZZZ" # Ensures that grand mean is plotted last (ie on top of individual participants)
GM_GFP$Colour <- "a"
IndGFPs$Colour <- "b"
PlotData <- rbind(IndGFPs, GM_GFP)
myPlot <- ggplot(data=PlotData, aes(x = time, y = Amplitude, group = SubNum, colour = Colour)) +
geom_freqpoly(stat = "identity", size = I(.3)) +
ggtitle(Title) +
scale_y_continuous("Amplitude / fT",limits=c(0,140),breaks=seq(0, 140, 20)) +
scale_x_continuous("Time / ms",limits=c(-100,400),breaks=seq(-100, 400, 100)) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5), legend.position="none", axis.line = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank()) +
scale_colour_manual(values=c("black", "grey"))
myPlot
}
Apply the GFP_Plot function to each response.
GFP_ACC_Onset <- GFP_Plot ("Onset", Title="mACC Onset")
GFP_ACC_Pitch <- GFP_Plot ("Pitch.Up", Title="mACC Pitch Change")
GFP_ACC_Vowel <- GFP_Plot ("Vowel.EU", Title="mACC Vowel Change")
GFP_MMF_Standard <- GFP_Plot ("standard", Title ="MMF Standard")
GFP_MMF_Pitch <- GFP_Plot ("Pitch.MMF", Title="MMF Pitch Change")
GFP_MMF_Vowel <- GFP_Plot ("Vowel.MMF", Title="MMF Vowel Change")
Combine into a six panel figure and output as a PNG file. This is Figure 2 in the paper.
png(filename="output/figures/Fig2.png", width=1000, height=600)
grid.arrange (GFP_ACC_Onset, GFP_ACC_Pitch, GFP_ACC_Vowel, GFP_MMF_Standard, GFP_MMF_Pitch, GFP_MMF_Vowel, ncol=3, nrow =2, widths=c(2.3, 2.3, 2.3), heights=c(2.3, 2.3))
dev.off()
## quartz_off_screen
## 2
knitr::include_graphics("output/figures/Fig2.png")

Source waveforms
Read in the SWFs dataframe.
SWFs <- read.csv("output/data/SWFs.csv", stringsAsFactors=TRUE)
str(SWFs)
## 'data.frame': 49140 obs. of 7 variables:
## $ X : int 1 2 3 4 5 6 7 8 9 10 ...
## $ time : int -100 -96 -92 -88 -84 -80 -76 -72 -68 -64 ...
## $ Response : Factor w/ 13 levels "Offset","Onset",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ Amplitude : num -2.97 -1.79 -1.08 -1.07 -1.7 ...
## $ SubNum : Factor w/ 15 levels "S019","S392",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Paradigm : Factor w/ 2 levels "ACC","MMF": 1 1 1 1 1 1 1 1 1 1 ...
## $ Hemisphere: Factor w/ 2 levels "L","R": 1 1 1 1 1 1 1 1 1 1 ...
Define the SWF_Plot function. This plots the left and right source waveforms for a specified response, taking as input the SWFs dataframe. It plots the SWF for each individual participant and overlays the grand mean (average across participants).
SWF_Plot <- function (Response, Title="") {
require(plyr)
require(ggplot2)
IndSWFs <- SWFs[(SWFs$Response==Response),]
IndSWFs$X <- NULL
GM_SWF <- ddply(IndSWFs, .(Paradigm, Response, Hemisphere, time), summarize, Amplitude = mean(Amplitude))
GM_SWF$SubNum <- "ZZZ"
GM_SWF$Colour <- "a"
IndSWFs$Colour <- "b"
PlotData <- rbind(GM_SWF, IndSWFs)
myPlot <- ggplot(data=PlotData, aes(x = time, y = Amplitude, group = SubNum, colour = Colour)) +
geom_freqpoly(stat = "identity", size = I(.3)) +
facet_grid(.~Hemisphere)+
ggtitle(Title) + theme(plot.title = element_text(size = 16, hjust = 0.2, vjust = 0.8)) +
scale_y_continuous("Amplitude",limits=c(-550,250),breaks=seq(-500, 200, 100)) +
scale_x_continuous("Time / ms",limits=c(-100,400),breaks=seq(-100, 400, 100)) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5), legend.position="none", axis.line = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank()) +
theme(strip.background = element_blank()) +
scale_colour_manual(values=c("black", "grey"))
myPlot
}
Apply the GFP_Plot function to each response.
ACC_Onset <- SWF_Plot ("Onset", Title="mACC Onset")
ACC_Pitch <- SWF_Plot ("Pitch.Up", Title="mACC Pitch Change")
ACC_Vowel <- SWF_Plot ("Vowel.EU", Title="mACC Vowel Change")
MMF_Standard <- SWF_Plot ("standard", Title ="MMF Standard")
MMF_Pitch <- SWF_Plot ("Pitch.MMF", Title="MMF Pitch Change")
MMF_Vowel <- SWF_Plot ("Vowel.MMF", Title="MMF Vowel Change")
Combine into a six panel figure.
png(filename="output/figures/Fig3_temp.png", width=1000, height=600)
grid.arrange (ACC_Onset, ACC_Pitch, ACC_Vowel, MMF_Standard, MMF_Pitch, MMF_Vowel, ncol=3, nrow =2, widths=c(5, 5, 5), heights=c(2.3, 2.3))
dev.off()
## quartz_off_screen
## 2
knitr::include_graphics("output/figures/Fig3_temp.png")

One participant shows an extremely noisy response in the source waveform. We therefore exclude this participant, replot the source waveforms, and output as a PNG file. This is Figure 3 in the paper.
GFPs <- GFPs[(GFPs$SubNum != "S930"),]
GFPs$SubNum <- factor(GFPs$SubNum)
SWFs <- SWFs[(SWFs$SubNum != "S930"),]
SWFs$SubNum <- factor(SWFs$SubNum)
ACC_Onset <- SWF_Plot ("Onset", Title="mACC Onset")
ACC_Pitch <- SWF_Plot ("Pitch.Up", Title="mACC Pitch Change")
ACC_Vowel <- SWF_Plot ("Vowel.EU", Title="mACC Vowel Change")
MMF_Standard <- SWF_Plot ("standard", Title ="MMF Standard")
MMF_Pitch <- SWF_Plot ("Pitch.MMF", Title="MMF Pitch Change")
MMF_Vowel <- SWF_Plot ("Vowel.MMF", Title="MMF Vowel Change")
png(filename="output/figures/Fig3.png", width=1000, height=600)
grid.arrange (ACC_Onset, ACC_Pitch, ACC_Vowel, MMF_Standard, MMF_Pitch, MMF_Vowel, ncol=3, nrow =2, widths=c(5, 5, 5), heights=c(2.3, 2.3))
dev.off()
## quartz_off_screen
## 2
knitr::include_graphics("output/figures/Fig3.png")

Peak amplitude and signal to noise ratio (SNR)
Data for statistical analyses are extracted from the waveform data using the get_SignalNoiseData function. Peak amplitudes (maximum for mACC and minimum for MMF) are extracted for each participant from a 100ms window centred on the peak amplitude in the grand mean GFP. SNR is calculated by dividing the root-mean square (RMS) of the post-stimulus-onset period (0 to 400ms) by the RMS of the baseline(-100 to 0).
get_SignalNoiseData <- function (Response) {
require(plyr)
GM_GFP <- ddply(GFPs[(GFPs$Response==Response)&(GFPs$time>0),], .(Response, time), summarize, Amplitude = mean(Amplitude))
GM_GFP_PeakTime <- as.numeric(which.max(GM_GFP$Amplitude)*4)
PeakWindow <- SWFs[(SWFs$Response==Response)&(SWFs$time>=GM_GFP_PeakTime-50)&(SWFs$time<=GM_GFP_PeakTime+50),]
if(substr(Response, 7, 9)=="MMF") {
Paradigm <- "MMF"
PeakDF <- ddply(PeakWindow, .(SubNum, Hemisphere), summarize, PeakAmplitude = -1*min(Amplitude))
} else {
Paradigm <- "mACC"
PeakDF <- ddply(PeakWindow, .(SubNum, Hemisphere), summarize, PeakAmplitude = max(Amplitude))
}
SignalWindow <- SWFs[(SWFs$Response==Response)&(SWFs$time>0)&(SWFs$time<=400),]
SignalDF <- ddply(SignalWindow, .(SubNum, Hemisphere), summarize, SignalRMS = sqrt(mean(Amplitude^2)))
SignalRMS <- SignalDF$SignalRMS
NoiseWindow <- SWFs[(SWFs$Response==Response)&(SWFs$time>=-100)&(SWFs$time<=0),]
NoiseDF <- ddply(NoiseWindow, .(SubNum, Hemisphere), summarize, NoiseRMS = sqrt(mean(Amplitude^2)))
NoiseRMS <- NoiseDF$NoiseRMS
SignalNoiseDF <- cbind(PeakDF, SignalRMS,NoiseRMS)
SignalNoiseDF$SNR <- SignalNoiseDF$SignalRMS / SignalNoiseDF$NoiseRMS
SignalNoiseDF$Stimulus <- as.factor(substr(Response, 1, 5))
SignalNoiseDF$Paradigm <- as.factor(Paradigm)
SignalNoiseDF
}
Apply the get_SignalNoiseData function to each of the four responses of interest and then concatenate into one long dataframe.
MMF_Pitch <- get_SignalNoiseData ("Pitch.MMF")
MMF_Vowel <- get_SignalNoiseData ("Vowel.MMF")
ACC_Pitch <- get_SignalNoiseData ("Pitch.Up")
ACC_Vowel <- get_SignalNoiseData ("Vowel.EU")
SignalNoise <- rbind(MMF_Pitch, MMF_Vowel, ACC_Pitch, ACC_Vowel)
str(SignalNoise)
## 'data.frame': 112 obs. of 8 variables:
## $ SubNum : Factor w/ 14 levels "S019","S392",..: 1 1 2 2 3 3 4 4 5 5 ...
## $ Hemisphere : Factor w/ 2 levels "L","R": 1 2 1 2 1 2 1 2 1 2 ...
## $ PeakAmplitude: num 76 53.9 55.7 44.1 164 ...
## $ SignalRMS : num 36.5 24.9 30.4 22.7 64.5 ...
## $ NoiseRMS : num 10.54 5.61 3.39 9.39 12.56 ...
## $ SNR : num 3.46 4.43 8.97 2.42 5.14 ...
## $ Stimulus : Factor w/ 2 levels "Pitch","Vowel": 1 1 1 1 1 1 1 1 1 1 ...
## $ Paradigm : Factor w/ 2 levels "MMF","mACC": 1 1 1 1 1 1 1 1 1 1 ...
Generate boxplots for Peak Amplitude and Signal to Noise Ratio.
Fig4a <- ggplot(SignalNoise, aes(factor(Stimulus), y=PeakAmplitude, fill=Hemisphere))+
facet_grid(.~Paradigm)+
geom_boxplot(outlier.colour=NA)+
scale_fill_brewer(palette="RdBu") +
theme_bw(base_size = 24, base_family = "") +
theme(strip.background = element_blank()) +
theme(plot.margin=unit(c(5.5, 35.5, 5.5, 5.5), "points")) +
scale_x_discrete("")+
geom_point(position=position_jitterdodge(dodge.width=0.75, jitter.width=0.3), alpha=0.2, size=3)+
scale_y_continuous("Peak Amplitude", breaks=seq(0, 800, 100))+
theme(axis.title.y = element_text(vjust=1.0))
Fig4b <- ggplot(SignalNoise, aes(factor(Stimulus), y=SNR, fill=Hemisphere))+
facet_grid(.~Paradigm)+
geom_boxplot(outlier.colour=NA)+
scale_fill_brewer(palette="RdBu") +
theme_bw(base_size = 24, base_family = "") +
theme(strip.background = element_blank()) +
theme(plot.margin=unit(c(5.5, 35.5, 5.5, 5.5), "points")) +
scale_x_discrete("")+
geom_point(position=position_jitterdodge(dodge.width=0.75, jitter.width=0.3), alpha=0.2, size=3)+
scale_y_continuous("Signal to Noise Ratio", breaks=seq(0, 100, 10))+
theme(axis.title.y = element_text(vjust=1.0))
Combine into a single figure and output to PNG file. This is Figure 4 in the paper
png(filename="output/figures/Fig4.png", width=1000, height=500)
grid.arrange (Fig4a+theme(legend.position="none"), Fig4b+theme(legend.position="none"), ncol=2, nrow =1, widths=c(2.3, 2.3), heights=c(2.3))
dev.off()
## quartz_off_screen
## 2
knitr::include_graphics("output/figures/Fig4.png")

Statistical analyses
Data are analysed using the ezANOVA function from the ez package. Type 3 produces the same results as the equivalent ANOVAs conducted in SPSS.
Peak amplitude
Three-way ANOVA shows significantly larger response to Vowel than to Pitch and an interaction between Paradigm and Stimulus
PeakAmpANOVA <- ezANOVA(SignalNoise, dv = PeakAmplitude, wid = SubNum, within = .(Paradigm, Stimulus, Hemisphere), type = 3)
kable(PeakAmpANOVA, row.names=FALSE, caption="ANOVA: Peak amplitude", digits=3)
ANOVA: Peak amplitude
| Paradigm |
1 |
13 |
0.544 |
0.474 |
|
0.008 |
| Stimulus |
1 |
13 |
6.104 |
0.028 |
* |
0.017 |
| Hemisphere |
1 |
13 |
1.415 |
0.255 |
|
0.026 |
| Paradigm:Stimulus |
1 |
13 |
23.026 |
0.000 |
* |
0.061 |
| Paradigm:Hemisphere |
1 |
13 |
1.712 |
0.213 |
|
0.014 |
| Stimulus:Hemisphere |
1 |
13 |
0.689 |
0.422 |
|
0.002 |
| Paradigm:Stimulus:Hemisphere |
1 |
13 |
0.850 |
0.373 |
|
0.003 |
|
Analysing the data separately for the mACC and MMF shows a significant effect of Stimulus for both paradigms. However, as indicated by the boxplot, the effects are in opposite directions. For the mACC, the response to Pitch is largest. For the MMF, the vowel response is largest.
PeakAmpANOVA_mACC <- ezANOVA(SignalNoise [(SignalNoise$Paradigm=="mACC"), ], dv = PeakAmplitude, wid = SubNum, within = .(Stimulus, Hemisphere), type = 3)
kable(PeakAmpANOVA_mACC, row.names=FALSE, caption="ANOVA: Peak amplitude for mACC", digits=3)
ANOVA: Peak amplitude for mACC
| Stimulus |
1 |
13 |
8.298 |
0.013 |
* |
0.027 |
| Hemisphere |
1 |
13 |
0.131 |
0.724 |
|
0.003 |
| Stimulus:Hemisphere |
1 |
13 |
0.017 |
0.897 |
|
0.000 |
|
PeakAmpANOVA_MMF <- ezANOVA(SignalNoise [(SignalNoise$Paradigm=="MMF"), ], dv = PeakAmplitude, wid = SubNum, within = .(Stimulus, Hemisphere), type = 3)
kable(PeakAmpANOVA_MMF, row.names=FALSE, caption="ANOVA: Peak amplitude for MMF", digits=3)
ANOVA: Peak amplitude for MMF
| Stimulus |
1 |
13 |
15.872 |
0.002 |
* |
0.094 |
| Hemisphere |
1 |
13 |
2.005 |
0.180 |
|
0.053 |
| Stimulus:Hemisphere |
1 |
13 |
0.838 |
0.377 |
|
0.007 |
|
Analysing the Peak Amplitude separately for Pitch and Vowel stimuli shows no significant differences between paradigms.
PeakAmpANOVA_Pitch <- ezANOVA(SignalNoise [(SignalNoise$Stimulus=="Pitch"), ], dv = PeakAmplitude, wid = SubNum, within = .(Paradigm, Hemisphere), type = 3)
kable(PeakAmpANOVA_Pitch, row.names=FALSE, caption="ANOVA: Peak amplitude for Pitch", digits=3)
ANOVA: Peak amplitude for Pitch
| Paradigm |
1 |
13 |
2.953 |
0.109 |
|
0.044 |
| Hemisphere |
1 |
13 |
1.208 |
0.292 |
|
0.022 |
| Paradigm:Hemisphere |
1 |
13 |
1.062 |
0.322 |
|
0.008 |
|
PeakAmpANOVA_Vowel <- ezANOVA(SignalNoise [(SignalNoise$Stimulus=="Vowel"), ], dv = PeakAmplitude, wid = SubNum, within = .(Paradigm, Hemisphere), type = 3)
kable(PeakAmpANOVA_Vowel, row.names=FALSE, caption="ANOVA: Peak amplitude for Vowel", digits=3)
ANOVA: Peak amplitude for Vowel
| Paradigm |
1 |
13 |
4.367 |
0.057 |
|
0.079 |
| Hemisphere |
1 |
13 |
1.341 |
0.268 |
|
0.030 |
| Paradigm:Hemisphere |
1 |
13 |
1.570 |
0.232 |
|
0.020 |
|
Signal to Noise Ratio
Three-way ANOVA again shows a main effect of Stimulus and an interaction between Paradigm and Stimulus.
SNR_ANOVA <- ezANOVA(SignalNoise, dv = SNR, wid = SubNum, within = .(Paradigm, Stimulus, Hemisphere), type = 3)
kable(SNR_ANOVA, row.names=FALSE, caption="ANOVA: Signal to noise ratio", digits=3)
ANOVA: Signal to noise ratio
| Paradigm |
1 |
13 |
2.638 |
0.128 |
|
0.048 |
| Stimulus |
1 |
13 |
4.708 |
0.049 |
* |
0.036 |
| Hemisphere |
1 |
13 |
0.721 |
0.411 |
|
0.005 |
| Paradigm:Stimulus |
1 |
13 |
7.816 |
0.015 |
* |
0.039 |
| Paradigm:Hemisphere |
1 |
13 |
0.047 |
0.831 |
|
0.000 |
| Stimulus:Hemisphere |
1 |
13 |
0.005 |
0.943 |
|
0.000 |
| Paradigm:Stimulus:Hemisphere |
1 |
13 |
3.177 |
0.098 |
|
0.010 |
|
Analysing the data separately for the mACC and MMF shows a larger response for vowel compared to pitch change for the MMF. However, in contrast to the Peak Amplitude analysis, the mACC response is similar for pitch and vowel changes.
SNR_ANOVA_mACC <- ezANOVA(SignalNoise [(SignalNoise$Paradigm=="mACC"), ], dv = SNR, wid = SubNum, within = .(Stimulus, Hemisphere), type = 3)
kable(SNR_ANOVA_mACC, row.names=FALSE, caption="ANOVA: Signal to noise ratio for mACC", digits=3)
ANOVA: Signal to noise ratio for mACC
| Stimulus |
1 |
13 |
0.007 |
0.937 |
|
0.000 |
| Hemisphere |
1 |
13 |
0.961 |
0.345 |
|
0.005 |
| Stimulus:Hemisphere |
1 |
13 |
1.542 |
0.236 |
|
0.007 |
|
SNR_ANOVA_MMF <- ezANOVA(SignalNoise [(SignalNoise$Paradigm=="MMF"), ], dv = SNR, wid = SubNum, within = .(Stimulus, Hemisphere), type = 3)
kable(SNR_ANOVA_MMF, row.names=FALSE, caption="ANOVA: Signal to noise ratio for MMF", digits=3)
ANOVA: Signal to noise ratio for MMF
| Stimulus |
1 |
13 |
9.387 |
0.009 |
* |
0.192 |
| Hemisphere |
1 |
13 |
0.367 |
0.555 |
|
0.006 |
| Stimulus:Hemisphere |
1 |
13 |
1.514 |
0.240 |
|
0.017 |
|
The mACC has significantly higher SNR than the MMF for Pitch stimuli but there is no Paradigm effect for Vowel stimuli.
SNR_ANOVA_Pitch <- ezANOVA(SignalNoise [(SignalNoise$Stimulus=="Pitch"), ], dv = SNR, wid = SubNum, within = .(Paradigm, Hemisphere), type = 3)
kable(SNR_ANOVA_Pitch, row.names=FALSE, caption="ANOVA: Signal to noise ratio for Pitch", digits=3)
ANOVA: Signal to noise ratio for Pitch
| Paradigm |
1 |
13 |
9.448 |
0.009 |
* |
0.209 |
| Hemisphere |
1 |
13 |
0.913 |
0.357 |
|
0.006 |
| Paradigm:Hemisphere |
1 |
13 |
6.151 |
0.028 |
* |
0.018 |
|
SNR_ANOVA_Vowel <- ezANOVA(SignalNoise [(SignalNoise$Stimulus=="Vowel"), ], dv = SNR, wid = SubNum, within = .(Paradigm, Hemisphere), type = 3)
kable(SNR_ANOVA_Vowel, row.names=FALSE, caption="ANOVA: Signal to noise ratio for Vowel", digits=3)
ANOVA: Signal to noise ratio for Vowel
| Paradigm |
1 |
13 |
0.019 |
0.894 |
|
0.000 |
| Hemisphere |
1 |
13 |
0.346 |
0.566 |
|
0.004 |
| Paradigm:Hemisphere |
1 |
13 |
1.138 |
0.305 |
|
0.007 |
|
Re-analysis
Given the relatively small sample size and the potential for results to be driven by outliers, we re-ran the 3-way ANOVAs, excluding each participant in turn. In each case, the interaction was significant, so it could not be attributed to any individual outlier.
SubNumList <- unique(SignalNoise$SubNum)
df <- data.frame(ExcludedParticipant=character(length(SubNumList)),
Effect=character(length(SubNumList)),
DFn=numeric(length(SubNumList)),
DFd=numeric(length(SubNumList)),
F=numeric(length(SubNumList)),
p=numeric(length(SubNumList)),
ges=numeric(length(SubNumList)),
stringsAsFactors=FALSE)
for(i in 1:length(SubNumList)) {
ExcludedParticipant <- SubNumList[i]
TestANOVA <- ezANOVA(SignalNoise[(SignalNoise$SubNum != ExcludedParticipant),], dv = PeakAmplitude, wid = SubNum, within = .(Paradigm, Stimulus, Hemisphere), type = 3)
df$ExcludedParticipant[i] <- ExcludedParticipant
df$Effect [i] <- TestANOVA$ANOVA$Effect[4]
df$DFn [i] <- TestANOVA$ANOVA$DFn[4]
df$DFd [i] <- TestANOVA$ANOVA$DFd[4]
df$F [i] <- TestANOVA$ANOVA$F[4]
df$p [i] <- TestANOVA$ANOVA$p[4]
df$ges [i] <- TestANOVA$ANOVA$ges[4]
}
kable(df, row.names=FALSE, caption="Paradigm by Stimulus Interaction for Peak Amplitude", digits=3)
Paradigm by Stimulus Interaction for Peak Amplitude
| 1 |
Paradigm:Stimulus |
1 |
12 |
19.992 |
0.001 |
0.060 |
| 2 |
Paradigm:Stimulus |
1 |
12 |
27.641 |
0.000 |
0.071 |
| 3 |
Paradigm:Stimulus |
1 |
12 |
19.569 |
0.001 |
0.056 |
| 4 |
Paradigm:Stimulus |
1 |
12 |
25.482 |
0.000 |
0.069 |
| 5 |
Paradigm:Stimulus |
1 |
12 |
20.001 |
0.001 |
0.060 |
| 6 |
Paradigm:Stimulus |
1 |
12 |
19.190 |
0.001 |
0.060 |
| 7 |
Paradigm:Stimulus |
1 |
12 |
19.267 |
0.001 |
0.057 |
| 8 |
Paradigm:Stimulus |
1 |
12 |
19.846 |
0.001 |
0.058 |
| 9 |
Paradigm:Stimulus |
1 |
12 |
23.316 |
0.000 |
0.066 |
| 10 |
Paradigm:Stimulus |
1 |
12 |
19.292 |
0.001 |
0.061 |
| 11 |
Paradigm:Stimulus |
1 |
12 |
18.889 |
0.001 |
0.054 |
| 12 |
Paradigm:Stimulus |
1 |
12 |
27.024 |
0.000 |
0.068 |
| 13 |
Paradigm:Stimulus |
1 |
12 |
21.736 |
0.001 |
0.063 |
| 14 |
Paradigm:Stimulus |
1 |
12 |
22.325 |
0.000 |
0.065 |
for(i in 1:length(SubNumList)) {
ExcludedParticipant <- SubNumList[i]
TestANOVA <- ezANOVA(SignalNoise[(SignalNoise$SubNum != ExcludedParticipant),], dv = SNR, wid = SubNum, within = .(Paradigm, Stimulus, Hemisphere), type = 3)
df$ExcludedParticipant[i] <- ExcludedParticipant
df$Effect [i] <- TestANOVA$ANOVA$Effect[4]
df$DFn [i] <- TestANOVA$ANOVA$DFn[4]
df$DFd [i] <- TestANOVA$ANOVA$DFd[4]
df$F [i] <- TestANOVA$ANOVA$F[4]
df$p [i] <- TestANOVA$ANOVA$p[4]
df$ges [i] <- TestANOVA$ANOVA$ges[4]
}
kable(df, row.names=FALSE, caption="Paradigm by Stimulus Interaction for Signal to Noise Ratio", digits=3)
Paradigm by Stimulus Interaction for Signal to Noise Ratio
| 1 |
Paradigm:Stimulus |
1 |
12 |
6.314 |
0.027 |
0.046 |
| 2 |
Paradigm:Stimulus |
1 |
12 |
7.301 |
0.019 |
0.041 |
| 3 |
Paradigm:Stimulus |
1 |
12 |
7.326 |
0.019 |
0.039 |
| 4 |
Paradigm:Stimulus |
1 |
12 |
7.604 |
0.017 |
0.041 |
| 5 |
Paradigm:Stimulus |
1 |
12 |
6.025 |
0.030 |
0.032 |
| 6 |
Paradigm:Stimulus |
1 |
12 |
6.852 |
0.022 |
0.039 |
| 7 |
Paradigm:Stimulus |
1 |
12 |
7.262 |
0.019 |
0.044 |
| 8 |
Paradigm:Stimulus |
1 |
12 |
13.305 |
0.003 |
0.053 |
| 9 |
Paradigm:Stimulus |
1 |
12 |
6.744 |
0.023 |
0.037 |
| 10 |
Paradigm:Stimulus |
1 |
12 |
8.825 |
0.012 |
0.024 |
| 11 |
Paradigm:Stimulus |
1 |
12 |
6.811 |
0.023 |
0.038 |
| 12 |
Paradigm:Stimulus |
1 |
12 |
7.774 |
0.016 |
0.042 |
| 13 |
Paradigm:Stimulus |
1 |
12 |
6.996 |
0.021 |
0.039 |
| 14 |
Paradigm:Stimulus |
1 |
12 |
5.969 |
0.031 |
0.032 |