library(DoE.base)
## Loading required package: grid
## Loading required package: conf.design
## 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
A<-rep(c(-1,1),8)
A
## [1] -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1
B<-rep(c(-1,-1,1,1),4)
B
## [1] -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1
C<-rep(c(-1,-1,-1,-1,1,1,1,1),2)
C
## [1] -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1
D<-c(rep(-1,8),rep(1,8))
D
## [1] -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1
Yield<-c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
d11<-data.frame(A,B,C,D,Yield)
mod<-lm(Yield~ A * B * C * D , data=d11)
coef(mod)
## (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
halfnormal(mod)
##
## Significant effects (alpha=0.05, Lenth method):
## [1] A A:C A:D D
Based on the half normal plot, A, A:D, A:C and D appear to be significant because they are plotted away from the other effects.
mod1<-lm(Yield~ A + C + D + A : C + A : D , data=d11)
anova(mod1)
## Analysis of Variance Table
##
## Response: Yield
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 81.00 81.000 49.8462 3.456e-05 ***
## C 1 16.00 16.000 9.8462 0.0105485 *
## D 1 42.25 42.250 26.0000 0.0004647 ***
## A:C 1 72.25 72.250 44.4615 5.583e-05 ***
## A:D 1 64.00 64.000 39.3846 9.193e-05 ***
## Residuals 10 16.25 1.625
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The effects A, C, D, A:C and A:D are significant because their p-values are less than 0.05 and C was retained because A:C was included.