\[ y_{ijkl} = \mu + \alpha_i + \beta_j + \gamma_k + \alpha\beta_{ij} + \alpha\gamma_{ik} + \beta\gamma_{jk} + \alpha\beta\gamma_{ijk} + e_{ijkl} \]
Step 1: Full factorial
dat <- data.frame(
Ammonium = c(2, 2, 30, 30, 2, 2, 30, 30, 2, 2, 30, 30, 2, 2, 30, 30),
StirRate = c(100, 100, 100, 100, 150, 150, 150, 150, 100, 100, 100, 100, 150, 150, 150, 150),
Temperature = c(8, 8, 8, 8, 8, 8, 8, 8, 40, 40, 40, 40, 40, 40, 40, 40),
Density = c(14.68, 15.18, 15.12, 17.48,
7.54, 6.66, 12.46, 12.62,
10.95, 17.68, 12.65, 15.96,
8.03, 8.84, 14.96, 14.96))
library(GAD)
dat$Ammonium <- as.fixed(factor(dat$Ammonium))
dat$StirRate <- as.fixed(factor(dat$StirRate))
dat$Temperature <- as.fixed(factor(dat$Temperature))
model <- aov(
Density ~ Ammonium * StirRate * Temperature,
data = dat
)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.39 44.39 11.180 0.01018 *
## StirRate 1 70.69 70.69 17.804 0.00292 **
## Temperature 1 0.33 0.33 0.083 0.78117
## Ammonium:StirRate 1 28.12 28.12 7.082 0.02875 *
## Ammonium:Temperature 1 0.02 0.02 0.005 0.94281
## StirRate:Temperature 1 10.13 10.13 2.551 0.14889
## Ammonium:StirRate:Temperature 1 1.52 1.52 0.383 0.55341
## Residuals 8 31.76 3.97
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Step 2: Remove non-significant terms
Removed terms:
Temperature
Ammonium:Temperature
StirRate:Temperature
Ammonium:StirRate:Temperature
Step 3: Final ANOVA and Interaction Plot
final_model <- aov(
Density ~ Ammonium * StirRate,
data = dat
)
summary(final_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.39 44.39 12.17 0.004472 **
## StirRate 1 70.69 70.69 19.38 0.000861 ***
## Ammonium:StirRate 1 28.12 28.12 7.71 0.016751 *
## Residuals 12 43.76 3.65
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction.plot(
x.factor = dat$Ammonium,
trace.factor = dat$StirRate,
response = dat$Density,
xlab = "Ammonium",
ylab = "Mean Density",
trace.label = "Stir Rate"
)
The full factorial ANOVA shows that Ammonium, Stir Rate, and their interaction (AB) are significant at the 0.05 level of significance. The ABC, AC, and BC interactions are not significant and are removed from the model. Temperature is also removed because it is not significant.
The final model includes Ammonium (p = 0.0045), Stir Rate (p = 0.0009), and the AB interaction (p = 0.0168). The interaction plot shows that the effect of Ammonium on Density depends on the Stir Rate. Therefore, both factors and their interaction should be included in the final model.
library(agricolae)
design <- design.ab(
trt = c(2, 2, 2),
r = 3,
design = "rcbd",
seed = 711
)
design$book
## plots block A B C
## 1 101 1 2 1 2
## 2 102 1 2 2 2
## 3 103 1 1 2 2
## 4 104 1 1 1 2
## 5 105 1 1 1 1
## 6 106 1 1 2 1
## 7 107 1 2 1 1
## 8 108 1 2 2 1
## 9 109 2 2 2 1
## 10 110 2 1 2 1
## 11 111 2 2 2 2
## 12 112 2 1 2 2
## 13 113 2 2 1 2
## 14 114 2 1 1 2
## 15 115 2 2 1 1
## 16 116 2 1 1 1
## 17 117 3 1 2 1
## 18 118 3 1 2 2
## 19 119 3 1 1 1
## 20 120 3 2 1 2
## 21 121 3 2 1 1
## 22 122 3 2 2 1
## 23 123 3 1 1 2
## 24 124 3 2 2 2
A full (2^3) factorial experiment was designed using a randomized
complete block design (RCBD) with three replications. The experiment
consists of eight treatment combinations and 24 experimental units. The
design.ab() function from the agricolae package was used to
randomly assign the treatment combinations within each block. Each block
contains all eight treatment combinations.