if (FALSE) {
library(agridat)
data(shaw.oats)
dat <- shaw.oats
# sum(dat$yield) # 16309 matches Shaw p. 125
# sum( (dat$yield-mean(dat$yield)) ^2) # total SS matches Shaw p. 141
dat$year <- factor(dat$year)
libs(lattice)
dotplot(yield ~ gen|env, data=dat, groups=year,
main="shaw.oats",
par.settings=list(superpose.symbol=list(pch=c('2','3','4'))),
panel=function(x,y,...){
panel.dotplot(x,y,...)
panel.superpose(x,y,..., panel.groups=function(x,y,col.line,...) {
dd<-aggregate(y~x,data.frame(x,y),mean)
panel.xyplot(x=dd$x, y=dd$y, col=col.line, type="l")
})},
auto.key=TRUE)
# Shaw & Bose meticulously calculate the ANOVA table, p. 141
m1 <- aov(yield ~ year*env*block*gen - year:env:block:gen, dat)
anova(m1)
}
Run the code above in your browser using DataLab