Data Input and Levels according to 2k Factorial design:
We input the data of yield in a vector and (-,+) levels for each factor A, B, C, and D are taken using the rep command. But this can also be obtained by using the command “expand.grid(c(-1,1), c(-1,1), c(-1,1))”.
Then took all the data into a data frame named Data.
A<- rep(c(-1,1), 8)
B<- rep(rep(c(-1,1),each = 2), 4)
C<- rep(rep(c(-1,1),each = 4), 2)
D<- rep(c(-1,1),each = 8)
Yield <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
Data<- data.frame(A,B,C,D, Yield)
Data
## A B C D Yield
## 1 -1 -1 -1 -1 12
## 2 1 -1 -1 -1 18
## 3 -1 1 -1 -1 13
## 4 1 1 -1 -1 16
## 5 -1 -1 1 -1 17
## 6 1 -1 1 -1 15
## 7 -1 1 1 -1 20
## 8 1 1 1 -1 15
## 9 -1 -1 -1 1 10
## 10 1 -1 -1 1 25
## 11 -1 1 -1 1 13
## 12 1 1 -1 1 24
## 13 -1 -1 1 1 19
## 14 1 -1 1 1 21
## 15 -1 1 1 1 17
## 16 1 1 1 1 23Modeling the 2k design.
Model <- lm(Yield~A*B*C*D,data = Data)
coef(Model)
## (Intercept) A B C D
## 1.737500e+01 2.250000e+00 2.500000e-01 1.000000e+00 1.625000e+00
## A:B A:C B:C A:D B:D
## -3.750000e-01 -2.125000e+00 1.250000e-01 2.000000e+00 -1.027824e-16
## C:D A:B:C A:B:D A:C:D B:C:D
## -1.595946e-16 5.000000e-01 3.750000e-01 -1.250000e-01 -3.750000e-01
## A:B:C:D
## 5.000000e-01
#install.packages("DoE.base")
library(DoE.base)
halfnormal(Model)
Comment: We observe that Effects A, D, AC, and AD are significant, since these points lie far away in the half normal plot.
Model_Anova <- aov(Yield~A+C+D+A*C+A*D,data = Data)
summary(Model_Anova)
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 81.00 81.00 49.846 3.46e-05 ***
## C 1 16.00 16.00 9.846 0.010549 *
## D 1 42.25 42.25 26.000 0.000465 ***
## A:C 1 72.25 72.25 44.462 5.58e-05 ***
## A:D 1 64.00 64.00 39.385 9.19e-05 ***
## Residuals 10 16.25 1.62
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Comment: Main effects (A,C,D) and the interaction term (AC & AD) are significant at alpha =0.05.
interaction.plot(A,D,Yield)
Comment: The interaction between A and D is significant, since the lines are not parallel.
Interaction Plot between A and C.
interaction.plot(A,C,Yield)
Comment: The interaction between A and C is significant, since the lines are not parallel.
A<- rep(c(-1,1), 8)
B<- rep(rep(c(-1,1),each = 2), 4)
C<- rep(rep(c(-1,1),each = 4), 2)
D<- rep(c(-1,1),each = 8)
Yield <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
Data<- data.frame(A,B,C,D, Yield)
Model <- lm(Yield~A*B*C*D,data = Data)
coef(Model)
install.packages("DoE.base")
library(DoE.base)
halfnormal(Model)
Model_Anova <- aov(Yield~A+C+D+A*C+A*D,data = Data)
summary(Model_Anova)
interaction.plot(A,D,Yield)
interaction.plot(A,C,Yield)