# NOT RUN {
data(patterson.switchback)
dat <- patterson.switchback
# Create a numeric period variable
dat$p <- as.numeric(substring(dat$period,2))
# Need to use 'terms' to preserve the order of the model terms
m1 <- aov(terms(y ~ cow + p:cow + period + trt, keep.order=TRUE), data=dat)
anova(m1) # Match table 2 of Lowry
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value Pr(>F)
## cow 11 3466.0 315.091 57.1773 2.258e-06 ***
## cow:p 12 953.5 79.455 14.4182 0.0004017 ***
## period 1 19.7 19.740 3.5821 0.0950382 .
## trt 3 58.3 19.418 3.5237 0.0685092 .
## Residuals 8 44.1 5.511
# }
Run the code above in your browser using DataLab