# Normality for repeated measures 2x3 ANOVA in R

I've tried different suggestions for similar questions here, but so far I haven't been able to figure this out.

I have data from 5 subjects who performed a task under six different conditions, where I have two factors, A and B, A has 2 levels and B 3. I am interested in seeing whether there is an A, B, or AxB effect. This is what my data look like:

> data
A1B1       A1B2       A1B3       A2B1        A2B2      A2B3
<dbl>      <dbl>      <dbl>      <dbl>       <dbl>     <dbl>
1 0.23694106 0.24721370 0.24243452 0.18634988 0.185587802 0.2272034
2 0.28706070 0.29954235 0.26044499 0.22570883 0.249875419 0.2134954
3 0.10159571 0.14058360 0.08654673 0.05068541 0.031204063 0.0278373
4 0.21372617 0.15595512 0.18168078 0.22170997 0.137082131 0.1698777
5 0.04138218 0.01654181 0.02714175 0.02570313 0.006663436 0.0648169


This is how I structured the data frame:

nsubs<-length(data$Var1) resp<-c(data$A1B1,data$A1B2,data$A1B3,data$A2B1,data$A2B2,data$A2B3) myData<-data.frame(subs=rep(seq(from=1, to= nsubs, by=1),6),response=resp,A=c(rep("A1", nsubs*3),rep("A2", nsubs*3)),B=c(rep("B1", nsubs),rep("B2", nsubs),rep("B3", nsubs), rep("B1", nsubs),rep("B2", nsubs),rep("B3", nsubs))) myData<-within(myData,{subs <-factor(subs) A<-factor(A) B<-factor(B)})  So myData looks so:  subs response A B 1 1 0.236941060 A1 B1 2 2 0.287060695 A1 B1 3 3 0.101595710 A1 B1 4 4 0.213726170 A1 B1 5 5 0.041382181 A1 B1 6 1 0.247213703 A1 B2 7 2 0.299542346 A1 B2 8 3 0.140583600 A1 B2 9 4 0.155955122 A1 B2 10 5 0.016541809 A1 B2 11 1 0.242434520 A1 B3 12 2 0.260444991 A1 B3 13 3 0.086546733 A1 B3 14 4 0.181680780 A1 B3 15 5 0.027141747 A1 B3 16 1 0.186349883 A2 B1 17 2 0.225708832 A2 B1 18 3 0.050685407 A2 B1 19 4 0.221709965 A2 B1 20 5 0.025703135 A2 B1 21 1 0.185587802 A2 B2 22 2 0.249875419 A2 B2 23 3 0.031204063 A2 B2 24 4 0.137082131 A2 B2 25 5 0.006663436 A2 B2 26 1 0.227203355 A2 B3 27 2 0.213495365 A2 B3 28 3 0.027837305 A2 B3 29 4 0.169877668 A2 B3 30 5 0.064816901 A2 B3  I can then run a repeated measures 2x3 ANOVA: response.aov<-with(myData,aov(response ~ A * B + Error(subs /(A*B)))) print(summary(response.aov))  The problem is that first I should make sure the residuals are normally distributed. I've tried myData.res = ERP myData.res$M1.Fit = fitted(myData.mod1)
myData.res$M1.Resid = resid(myData.mod1) print(ggplot(myData.res, aes(sample = M1.Resid)) + stat_qq()) result <- shapiro.test(myData.res$M1.Resid)


however, fitted(myData.mod1) returns NULL. I also tried:

m <- aov(resp ~ A*B+Error(subs /(A*B)), data=myData)
m.res<-proj(m)


but m.res contains residuals for subs, subs:A, subs:B, and subs:A:B. Which are the relevant residuals? Does anyone know a better method for checking normality for this design?

• This link may be helpful: stackoverflow.com/questions/26169153/… Oct 24, 2017 at 16:13
• Oct 24, 2017 at 16:24
• A different approach would be to conduct the repeated measures analysis with a mixed model. The following gives an example of a model in both aov and with lme. stats.stackexchange.com/questions/188230/… . It is easy to get the residuals from the lme object. Oct 24, 2017 at 16:42
• Or to use lme or gls with a correlation structure. The answer and comments here have some very useful information about the assumptions in using aov for repeated measures and how to use lme or gls in an equivalent way: stats.stackexchange.com/questions/14088/… . Oct 24, 2017 at 17:09