# Example from book of Box, Hunter, Hunter on lima beans. # A: depth of planting (0.5 in or 1.5 in) # B: watering (once or twice daily) # C: type of bean (baby or large) # Y: yield a<-rep(c(-1,1),4) b<-rep(c(-1,-1,1,1),2) c<-c(rep(-1,4),rep(1,4)) ab<-a*b; ac<-a*c; bc<-b*c; abc<-a*b*c y <- c(6,4,10,7,4,3,8,5) summary(lm(y~a+b+c+ab+ac+bc+abc)) summary(lm(y~(a+b+c)^3)) # easier - using model formula notation # note: "a:b" in output means entrywise multiplication of columns in design matrix, i.e. the same as the multiplication above. # Even easier: library(FrF2) plan <- FrF2(nruns=8,nfactors=3,randomize=FALSE) plan plan <- add.response(plan,y) plan # now we have an ordinary data set up to be used with lm lm3 <- lm(y~.^3,data=plan) summary(lm3) MEPlot(lm3) # dev.copy2pdf(file="LimaME.pdf") IAPlot(lm3) # dev.copy2pdf(file="LimaIA.pdf") effects <- 2*lm3$coeff effects