An engineer is interested in the effects of cutting speed A, tool geometry B, and cutting angle C on the life (in hours) of a machine tool. Two levels of each factor are chosen, and three replicates of a 24 factorial design are run.
A <- c(rep(c(-1,1),12))
B <- rep(c(-1,-1,1,1),6)
C <- rep(c(-1,-1,-1,-1,1,1,1,1),3)
rep1 <- c(22,32,35,55,44,40,60,39)
rep2 <- c(31,43,34,47,45,37,50,41)
rep3 <- c(25,29,50,46,38,36,54,47)
reps <- c(rep1,rep2,rep3)
A <- as.fixed(A)
B <- as.fixed(B)
C <- as.fixed(C)
dat <- data.frame(A,B,C,reps)
mod <- lm(reps~A+B+C+A*B+A*C+B*C+A*B*C, data = dat)
gad(mod)
## Analysis of Variance Table
##
## Response: reps
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 0.67 0.67 0.0221 0.8836803
## B 1 770.67 770.67 25.5470 0.0001173 ***
## C 1 280.17 280.17 9.2873 0.0076787 **
## A:B 1 16.67 16.67 0.5525 0.4680784
## A:C 1 468.17 468.17 15.5193 0.0011722 **
## B:C 1 48.17 48.17 1.5967 0.2244753
## A:B:C 1 28.17 28.17 0.9337 0.3482825
## Residual 16 482.67 30.17
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction.plot(A,C,reps)
\(~\)
In a process development study on yield, four factors were studied, each at two levels: time (A), concentration (B), pressure (C), and temperature (D).
Ai <- c(rep(c(-1,1),8))
Bi <- rep(c(-1,-1,1,1),4)
Ci <- rep(c(-1,-1,-1,-1,1,1,1,1),2)
Di <- c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
rn <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
aro <- c(5,9,8,13,3,7,14,1,6,11,2,15,4,16,10,12)
yield <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
dat2 <- data.frame(Ai,Bi,Ci,Di,yield)
mod2 <- lm(yield~Ai*Bi*Ci*Di, data = dat2)
coef(mod2)
## (Intercept) Ai Bi Ci Di
## 1.737500e+01 2.250000e+00 2.500000e-01 1.000000e+00 1.625000e+00
## Ai:Bi Ai:Ci Bi:Ci Ai:Di Bi:Di
## -3.750000e-01 -2.125000e+00 1.250000e-01 2.000000e+00 -8.543513e-17
## Ci:Di Ai:Bi:Ci Ai:Bi:Di Ai:Ci:Di Bi:Ci:Di
## 1.110223e-16 5.000000e-01 3.750000e-01 -1.250000e-01 -3.750000e-01
## Ai:Bi:Ci:Di
## 5.000000e-01
halfnormal(mod2)
##
## Significant effects (alpha=0.05, Lenth method):
## [1] Ai Ai:Ci Ai:Di Di
# 1
#Factorial Design
A <- c(rep(c(-1,1),12))
B <- rep(c(-1,-1,1,1),6)
C <- rep(c(-1,-1,-1,-1,1,1,1,1),3)
rep1 <- c(22,32,35,55,44,40,60,39)
rep2 <- c(31,43,34,47,45,37,50,41)
rep3 <- c(25,29,50,46,38,36,54,47)
reps <- c(rep1,rep2,rep3)
A <- as.fixed(A)
B <- as.fixed(B)
C <- as.fixed(C)
dat <- data.frame(A,B,C,reps)
mod <- lm(reps~A+B+C+A*B+A*C+B*C+A*B*C, data = dat)
gad(mod)
interaction.plot(A,C,reps)
#2
# Half Normal Model
Ai <- c(rep(c(-1,1),8))
Bi <- rep(c(-1,-1,1,1),4)
Ci <- rep(c(-1,-1,-1,-1,1,1,1,1),2)
Di <- c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
rn <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
aro <- c(5,9,8,13,3,7,14,1,6,11,2,15,4,16,10,12)
yield <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
dat2 <- data.frame(Ai,Bi,Ci,Di,yield)
mod2 <- lm(yield~Ai*Bi*Ci*Di, data = dat2)
coef(mod2)
halfnormal(mod2)