data <- matrix(scan(),ncol=6,byrow=TRUE) 1 1 1 1 1 14 1 1 1 0 0 11.5 1 1 0 1 0 12 1 1 0 0 1 12.5 2 3 1 1 1 10 2 3 1 0 0 8 2 3 0 1 0 7 2 3 0 0 1 9 1 2 1 1 0 13 1 2 1 0 1 14 1 2 0 1 1 13 1 2 0 0 0 10 2 4 1 1 0 13 2 4 1 0 1 15 2 4 0 1 1 14 2 4 0 0 0 11 data Burgers1 <- data.frame(data) colnames(Burgers1) <- c("rep","person","patty","cheese","mayo","taste") Burgers1$rep <- as.factor(Burgers1$rep) Burgers1$person <- as.factor(Burgers1$person) Burgers1$patty <- as.factor(Burgers1$patty) Burgers1$mayo <- as.factor(Burgers1$mayo) Burgers1$cheese <- as.factor(Burgers1$cheese) summary(aov(taste ~ rep + Error(rep/person) + patty*mayo*cheese, data = Burgers1)) # it is easier to see the results using the afex package library(afex) Burgers1.afex1 <- mixed(taste ~ rep + (1|rep:person) +patty*mayo*cheese -patty:mayo:cheese, data = Burgers1) summary(Burgers1.afex1) nice(Burgers1.afex1) # looking at the nearly significant interaction lsmip(Burgers1.afex1, mayo ~ cheese) # this approach is like the split-plot approach from Chapter 14 Burgers1 <- within(Burgers1, { ABC <- NA ABC[person == 1] <- 'odd' ABC[person == 2] <- 'even' ABC[person == 3] <- 'odd' ABC[person == 4] <- 'even' } ) Burgers1.afexSPF <- mixed(taste ~ ABC + (1|rep:ABC) +patty*mayo*cheese -patty:mayo:cheese, data = Burgers1) summary(Burgers1.afexSPF) nice(Burgers1.afexSPF) lsmeans(Burgers1.afexSPF, ~mayo)