This slide was presented in Tokyo.R #22.It describes about design of experiment with R. DoE.base package is useful for software testing because it makes easier for us to make orthogonal array.
20
Rによる分析
二元配置分散分析
A <- paste("A",c(1,1,1,1,2,2,2,2),sep="")
と同様にできる!
B <- paste("B",c(1,1,2,2,2,2,1,1),sep="")
C <- paste("C",c(1,2,1,2,2,1,2,1),sep="")
D <- paste("D",c(1,2,2,1,2,1,1,2),sep="")
V <- c(40,46,28,18,32,26,32,58)
data <- data.frame(A=A,B=B,C=C,D=D,V=V) BとDが有意な因子
result <- summary(aov(V~A+B+C+D,data=data)) と判断できる
38
補足:21枚目のグラフを描画するコード
A <- paste("A",c(1,1,1,1,2,2,2,2),sep="")
B <- paste("B",c(1,1,2,2,2,2,1,1),sep="")
C <- paste("C",c(1,2,1,2,2,1,2,1),sep="")
D <- paste("D",c(1,2,2,1,2,1,1,2),sep="")
V <- c(40,46,28,18,32,26,32,58)
data <- data.frame(A=A,B=B,C=C,D=D,V=V) # スライド中の強度実験データ
result <- summary(aov(V~A+B+C+D,data=data))
rng <- range(V) # 描画範囲を全部のグラフで設定しておく
f <- function(fac, val, rng){
res <- aggregate(val, by = list(fac) , FUN = mean )
p <- par(cex=1,mai=c(0.8,0.6,0.6,0.3))
plot(fac,val,ylim=rng,type="n")
par(p)
lines(res[,1],res[,2],col="red",lwd=5)
}
oldpar <- par(mfrow=c(2,2))
lapply(data[,1:4], f, data$V, rng)
par(oldpar)