One-way repeated measures ANOVA
If we have more than 2 levels of a within-subjects factor, we cannot use a paired t-test or paired wilcoxon signed rank test. For this we use a one-way repeated measures ANOVA. It is parametric.
A repeated-measures ANOVA will look over all the levels together. If the overall omnibus test is significant, we can then look at the post-hoc tests
One important concept is sphericity: this is when the variance of the differences between all combinations of levels of a within-Ss factor are equal. It always holds for within-Ss factors that have just 2 levels, but for 3+ levels, sphericity can be tested with Mauchly’s Test of Sphericity. If the test violates sphericity, we need to use correction.
1srchscrlvce = read.csv("srchscrlvce.csv")
2View(srchscrlvce)
3srchscrlvce$Subject = factor(srchscrlvce$Subject) # convert to nominal factor
4srchscrlvce$Technique = factor(srchscrlvce$Technique) # Rv4
5srchscrlvce$Order = factor(srchscrlvce$Order) # convert to nominal factor
6summary(srchscrlvce)
7
8library(plyr)
9ddply(srchscrlvce, ~ Technique, function(data) summary(data$Time))
10ddply(srchscrlvce, ~ Technique, summarise, Time.mean=mean(Time), Time.sd=sd(Time))
11
12hist(srchscrlvce[srchscrlvce$Technique == "Search",]$Time)
13hist(srchscrlvce[srchscrlvce$Technique == "Scroll",]$Time)
14hist(srchscrlvce[srchscrlvce$Technique == "Voice",]$Time) # new one
15plot(Time ~ Technique, data=srchscrlvce) # boxplot
16
17library(ez)
18m = ezANOVA(dv=Time, within=Technique, wid=Subject, type=3, data=srchscrlvce)
19m$Mauchly # p<.05 indicates a violation
20m$ANOVA
21pos = match(m$`Sphericity Corrections`$Effect, m$ANOVA$Effect) # positions of within-Ss efx in m$ANOVA
22m$Sphericity$GGe.DFn = m$Sphericity$GGe * m$ANOVA$DFn[pos] # Greenhouse-Geisser
23m$Sphericity$GGe.DFd = m$Sphericity$GGe * m$ANOVA$DFd[pos]
24m$Sphericity$HFe.DFn = m$Sphericity$HFe * m$ANOVA$DFn[pos] # Huynh-Feldt
25m$Sphericity$HFe.DFd = m$Sphericity$HFe * m$ANOVA$DFd[pos]
26m$Sphericity # show results
27
28m = aov(Time ~ Technique + Error(Subject/Technique), data=srchscrlvce) # fit model
29summary(m) # show anova
30
31library(reshape2)
32srchscrlvce.wide.tech = dcast(srchscrlvce, Subject ~ Technique, value.var="Time") # go wide
33View(srchscrlvce.wide.tech)
34se.sc = t.test(srchscrlvce.wide.tech$Search, srchscrlvce.wide.tech$Scroll, paired=TRUE)
35se.vc = t.test(srchscrlvce.wide.tech$Search, srchscrlvce.wide.tech$Voice, paired=TRUE)
36sc.vc = t.test(srchscrlvce.wide.tech$Scroll, srchscrlvce.wide.tech$Voice, paired=TRUE)
37p.adjust(c(se.sc$p.value, se.vc$p.value, sc.vc$p.value), method="holm")
References
#repeated_measures #friedman #rlang #statistics #designing_running_and_analyzing_experiments #anova #week6 #experiment #one_way_repeated_measures #sphericity #coursera #design #within_subjects #test #theory