Q1

a).

df <- expand.grid(
  A = c(-1, 1),
  B = c(-1, 1),
  C = c(-1, 1),
  D = c(-1, 1))
y <- c(12, 18, 13, 16,
       17, 15, 20, 15,
       10, 25, 13, 24,
       19, 21, 17, 23)
df$y <- y
df
##     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
library(FrF2)
## Loading required package: 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
model <- aov(y ~ A*B*C*D, data=df)
summary(model)
##             Df Sum Sq Mean Sq
## A            1  81.00   81.00
## B            1   1.00    1.00
## C            1  16.00   16.00
## D            1  42.25   42.25
## A:B          1   2.25    2.25
## A:C          1  72.25   72.25
## B:C          1   0.25    0.25
## A:D          1  64.00   64.00
## B:D          1   0.00    0.00
## C:D          1   0.00    0.00
## A:B:C        1   4.00    4.00
## A:B:D        1   2.25    2.25
## A:C:D        1   0.25    0.25
## B:C:D        1   2.25    2.25
## A:B:C:D      1   4.00    4.00
DanielPlot(model, half=TRUE)

Based on the plot, factors A, C, and D, as well as the two-factor interactions A:C and A:D, appear to be significant. The remaining effects are considered insignificant.

b).

model2 <- aov(y ~ A+C+D+A:C+A:D, data=df)
summary(model2)
##             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

The insignificant effects were pooled into the error term by fitting a reduced model containing A, C, D, A:C, and A:D. The resulting error sum of squares is 16.25, with 10 degrees of freedom. The mean square error is 1.625. At the 0.05 significance level, all five retained effects have p-values less than 0.05. Therefore, A, C, D, A:C, and A:D are statistically significant.