y <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
a <- c(-1,1)
b <- c(-1,-1,1,1)
c<- c(-1,-1,-1,-1,1,1,1,1)
d<- c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
A<- c(rep(a,8))
B<-c(rep(b,4))
C<-c(rep(c,2))
D<-c(rep(d,1))
Dat <-data.frame(A,B,C,D,y)
Dat
## A B C D y
## 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 23
Model <- lm(y~A*B*C*D, data=Dat)
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
library(DoE.base)
## Warning: package 'DoE.base' was built under R version 4.5.2
## Loading required package: grid
## Loading required package: conf.design
## Warning: package 'conf.design' was built under R version 4.5.2
## Registered S3 method overwritten by 'DoE.base':
## method from
## factorize.factor conf.design
##
## Attaching package: 'DoE.base'
## The following objects are masked from 'package:stats':
##
## aov, lm
## The following object is masked from 'package:graphics':
##
## plot.design
## The following object is masked from 'package:base':
##
## lengths
halfnormal(Model)
##
## Significant effects (alpha=0.05, Lenth method):
## [1] A A:C A:D D
Comment : Effect A,D,AD and AC are significant here as they don’t lie close to the normal line.
Writing the hypothesis :
Null: \(H_{\circ}\)
\[(\alpha \gamma)_{i,k} =0 \] \[(\alpha \lambda)_{i,l} = 0\] \[(\alpha)_{i}=0 \] \[ (\gamma)_{k}=0\] \[ (\lambda)_{l}=0\] Alternate : \(H_{a}\) \[(\alpha \gamma)_{i,k} \neq 0 \] \[(\alpha \lambda)_{i,l} \neq 0\] \[(\alpha)_{i} \neq 0 \] \[ (\gamma)_{k} \neq 0\] \[ (\lambda)_{l} \neq 0\] As AD and AC are also significant following factors will have to be considered A,C,D,AC,AD
Model1<- aov(y~A+B+C+D+A*C+A*D+A*B+B*C+B*D+C*D,data=Dat)
summary(Model1)
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 81.00 81.00 31.765 0.00244 **
## B 1 1.00 1.00 0.392 0.55864
## C 1 16.00 16.00 6.275 0.05416 .
## D 1 42.25 42.25 16.569 0.00963 **
## A:C 1 72.25 72.25 28.333 0.00313 **
## A:D 1 64.00 64.00 25.098 0.00407 **
## A:B 1 2.25 2.25 0.882 0.39068
## B:C 1 0.25 0.25 0.098 0.76684
## B:D 1 0.00 0.00 0.000 1.00000
## C:D 1 0.00 0.00 0.000 1.00000
## Residuals 5 12.75 2.55
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Conlusion: Based on the above values tested main effects A,D,AC,AD appear to be significant at alpha =0.05 as p values are less than 0.05
interaction.plot(A,D,y,col = c("red","blue"))
interaction.plot(A,C,y,col = c("red","blue"))