Problem 1

a).

Model equation for a full 2^3 factorial model \[Y_{ijkl} = \mu + \alpha_i + \beta_j+ \gamma_k + \alpha\beta_{ij}+ \alpha\gamma_{ik}+ \beta\gamma_{jk}+ \alpha\beta\gamma_{ijk}+ \varepsilon_{ijkl}\]

Where

\(Y_{ijkl}\) is Powder Density

\(\mu\) is Grand Mean

\(\alpha_i,\beta_j,\gamma_k\) are Main Effects of A, B, C

\(\alpha\beta_{ij},\alpha\gamma_{ik},\beta\gamma_{jk}\) are Two-Factor Interactions

\(\alpha\beta\gamma_{ijk}\) is Three-Factor Interaction

\(\varepsilon_{ijkl}\) is Random Error

b).

dat <- read.csv(text = "
Ammonium,StirRate,Temperature,Density
2,100,8,14.68
2,100,8,15.18
30,100,8,15.12
30,100,8,17.48
2,150,8,7.54
2,150,8,6.66
30,150,8,12.46
30,150,8,12.62
2,100,40,10.95
2,100,40,17.68
30,100,40,12.65
30,100,40,15.96
2,150,40,8.03
2,150,40,8.84
30,150,40,14.96
30,150,40,14.96
")

dat
##    Ammonium StirRate Temperature Density
## 1         2      100           8   14.68
## 2         2      100           8   15.18
## 3        30      100           8   15.12
## 4        30      100           8   17.48
## 5         2      150           8    7.54
## 6         2      150           8    6.66
## 7        30      150           8   12.46
## 8        30      150           8   12.62
## 9         2      100          40   10.95
## 10        2      100          40   17.68
## 11       30      100          40   12.65
## 12       30      100          40   15.96
## 13        2      150          40    8.03
## 14        2      150          40    8.84
## 15       30      150          40   14.96
## 16       30      150          40   14.96
dat$A <- factor(dat$Ammonium)
dat$B <- factor(dat$StirRate)
dat$C <- factor(dat$Temperature)

model <- lm(Density ~ A * B * C, data = dat)
anova(model)
## Analysis of Variance Table
## 
## Response: Density
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## A          1 44.389  44.389 11.1803 0.010175 * 
## B          1 70.686  70.686 17.8037 0.002918 **
## C          1  0.328   0.328  0.0826 0.781170   
## A:B        1 28.117  28.117  7.0817 0.028754 * 
## A:C        1  0.022   0.022  0.0055 0.942808   
## B:C        1 10.128  10.128  2.5510 0.148890   
## A:B:C      1  1.519   1.519  0.3826 0.553412   
## Residuals  8 31.762   3.970                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For ABC, Since p is 0.553412 > 0.05, the effect of ABC is not significant, therefore remove ABC from the model.

model2 <- lm(
  Density ~ A + B + C +
    A:B + A:C + B:C, data = dat)

anova(model2)
## Analysis of Variance Table
## 
## Response: Density
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## A          1 44.389  44.389 12.0037 0.007109 **
## B          1 70.686  70.686 19.1150 0.001792 **
## C          1  0.328   0.328  0.0886 0.772681   
## A:B        1 28.117  28.117  7.6033 0.022206 * 
## A:C        1  0.022   0.022  0.0059 0.940538   
## B:C        1 10.128  10.128  2.7389 0.132317   
## Residuals  9 33.281   3.698                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For AC, Since p is 0.940538 > 0.05, the effect of AC is not significant, therefore remove AC from the model.

model3 <- lm(
  Density ~ A + B + C +
    A:B + B:C, data = dat)

anova(model3)
## Analysis of Variance Table
## 
## Response: Density
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## A          1 44.389  44.389 13.3287 0.0044560 ** 
## B          1 70.686  70.686 21.2250 0.0009696 ***
## C          1  0.328   0.328  0.0984 0.7601850    
## A:B        1 28.117  28.117  8.4426 0.0156821 *  
## B:C        1 10.128  10.128  3.0412 0.1117751    
## Residuals 10 33.303   3.330                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For BC, Since p is 0.1117751 > 0.05, the effect of BC is not significant, therefore remove BC from the model.

model4 <- lm(
  Density ~ A + B + C +
    A:B, data = dat)

anova(model4)
## Analysis of Variance Table
## 
## Response: Density
##           Df Sum Sq Mean Sq F value   Pr(>F)   
## A          1 44.389  44.389 11.2425 0.006443 **
## B          1 70.686  70.686 17.9028 0.001410 **
## C          1  0.328   0.328  0.0830 0.778613   
## A:B        1 28.117  28.117  7.1211 0.021851 * 
## Residuals 11 43.431   3.948                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For C, Since p is 0.778613 > 0.05, the effect of C is not significant, therefore remove C from the model.

model5 <- lm(
  Density ~ A + B +
    A:B, data = dat)

anova(model5)
## Analysis of Variance Table
## 
## Response: Density
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## A          1 44.389  44.389 12.1727 0.0044721 ** 
## B          1 70.686  70.686 19.3841 0.0008612 ***
## A:B        1 28.117  28.117  7.7103 0.0167511 *  
## Residuals 12 43.759   3.647                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction.plot(
  dat$Ammonium,
  dat$StirRate,
  dat$Density,)

interaction.plot(
  dat$Ammonium,
  dat$Temperature,
  dat$Density,)

interaction.plot(
  dat$StirRate,
  dat$Temperature,
  dat$Density,)

The A×B interaction is significant, indicating that the effect of Ammonium on Density depends on the Stir Rate. The three-factor interaction was not significant and was removed first. The non-significant AC, BC, and Temperature effects were also removed. The final model includes Ammonium, Stir Rate, and their interaction. Their p-values are 0.00447, 0.00086, and 0.01675, respectively. Therefore, all three effects are significant at (α=0.05).

Problem 2

library(agricolae)
tomato_design <- design.ab(
  trt = c(2, 2, 2),
  r = 3,
  design = "rcbd",
  seed = 1208)
tomato_design$book
##    plots block A B C
## 1    101     1 1 2 1
## 2    102     1 1 1 2
## 3    103     1 2 2 1
## 4    104     1 2 1 1
## 5    105     1 2 1 2
## 6    106     1 1 1 1
## 7    107     1 2 2 2
## 8    108     1 1 2 2
## 9    109     2 1 2 2
## 10   110     2 2 1 2
## 11   111     2 1 2 1
## 12   112     2 1 1 1
## 13   113     2 1 1 2
## 14   114     2 2 2 2
## 15   115     2 2 1 1
## 16   116     2 2 2 1
## 17   117     3 2 2 1
## 18   118     3 1 2 1
## 19   119     3 2 1 1
## 20   120     3 1 1 1
## 21   121     3 1 1 2
## 22   122     3 2 1 2
## 23   123     3 1 2 2
## 24   124     3 2 2 2