The response is powder density (g/cm^2). The factors are Ammonium concentration (A), Stir Rate (B), and Temperature (C). Each of the eight treatment combinations has two observations.
powder <- data.frame(
Ammonium = factor(c(
2, 2, 30, 30, 2, 2, 30, 30,
2, 2, 30, 30, 2, 2, 30, 30
), levels = c(2, 30)),
StirRate = factor(c(
100, 100, 100, 100, 150, 150, 150, 150,
100, 100, 100, 100, 150, 150, 150, 150
), levels = c(100, 150)),
Temperature = factor(c(
8, 8, 8, 8, 8, 8, 8, 8,
40, 40, 40, 40, 40, 40, 40, 40
), levels = c(8, 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
)
)
powder
## 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
Let \(A\), \(B\), and \(C\) denote the coded factor levels, each taking values \(-1\) and \(+1\). The full factorial model includes all main effects and interactions:
\[ \begin{aligned} Y_{ijkl} ={}& \beta_0 + \beta_A A_i + \beta_B B_j + \beta_C C_k \\ &+ \beta_{AB} A_iB_j + \beta_{AC} A_iC_k + \beta_{BC} B_jC_k \\ &+ \beta_{ABC} A_iB_jC_k + \varepsilon_{ijkl}. \end{aligned} \]
Here, \(\varepsilon_{ijkl}\) are independent errors with mean zero and common variance.
Fit the full model in R using factor notation:
full_model <- lm(Density ~ Ammonium * StirRate * Temperature,
data = powder)
anova_full <- anova(full_model)
anova_full
## Analysis of Variance Table
##
## Response: Density
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.389 44.389 11.1803 0.010175 *
## StirRate 1 70.686 70.686 17.8037 0.002918 **
## Temperature 1 0.328 0.328 0.0826 0.781170
## Ammonium:StirRate 1 28.117 28.117 7.0817 0.028754 *
## Ammonium:Temperature 1 0.022 0.022 0.0055 0.942808
## StirRate:Temperature 1 10.128 10.128 2.5510 0.148890
## Ammonium:StirRate:Temperature 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
The p-values from the full factorial model are used to assess each term. A term is considered statistically significant when its p-value is less than 0.05.
p_values <- data.frame(
Term = rownames(anova_full),
`F value` = anova_full$`F value`,
`p-value` = anova_full$`Pr(>F)`,
row.names = NULL
)
p_values
## Term F.value p.value
## 1 Ammonium 11.180257443 0.010175227
## 2 StirRate 17.803734610 0.002918021
## 3 Temperature 0.082552141 0.781170009
## 4 Ammonium:StirRate 7.081719394 0.028754147
## 5 Ammonium:Temperature 0.005479758 0.942807665
## 6 StirRate:Temperature 2.551021886 0.148889937
## 7 Ammonium:StirRate:Temperature 0.382605506 0.553411659
## 8 Residuals NA NA
Based on the full model, the terms are:
Thus, the nonsignificant terms involving Temperature (Temperature, Ammonium × Temperature, Stir Rate × Temperature, and the three-factor interaction) are dropped. The reduced model retains Ammonium, Stir Rate, and their interaction. The two-factor interaction is retained with its main effects to respect model hierarchy.
reduced_model <- lm(Density ~ Ammonium * StirRate, data = powder)
anova_reduced <- anova(reduced_model)
anova_reduced
## Analysis of Variance Table
##
## Response: Density
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.389 44.389 12.1727 0.0044721 **
## StirRate 1 70.686 70.686 19.3841 0.0008612 ***
## Ammonium:StirRate 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
reduced_p_values <- data.frame(
Term = rownames(anova_reduced),
`F value` = anova_reduced$`F value`,
`p-value` = anova_reduced$`Pr(>F)`,
row.names = NULL
)
reduced_p_values
## Term F.value p.value
## 1 Ammonium 12.17268 0.0044721039
## 2 StirRate 19.38409 0.0008612499
## 3 Ammonium:StirRate 7.71033 0.0167510677
## 4 Residuals NA NA
In the reduced model, the final p-values are:
All three retained terms are significant at the 0.05 level.
The Ammonium × Stir Rate interaction is significant, so the interaction plot is included.
with(powder,
interaction.plot(
x.factor = StirRate,
trace.factor = Ammonium,
response = Density,
fun = mean,
type = "b",
pch = c(19, 17),
xlab = "Stir Rate (RPM)",
ylab = "Mean powder density (g/cm^2)",
trace.label = "Ammonium (%)"
))
The lines are not parallel, which is consistent with the significant Ammonium × Stir Rate interaction. The effect of Stir Rate on mean density depends on the Ammonium level.
The experiment has three two-level factors and three replications (blocks), giving \(2^3=8\) treatment combinations and \(8 \times 3 = 24\) experimental units.
Factor levels: - A: Fertilizer Type (1 = Organic compost, 2 = Chemical fertilizer) - B: Irrigation Frequency (1 = Once per day, 2 = Twice per day) - C: Temperature Setting (1 = 22°C, 2 = 28°C)
Use design.ab() from the agricolae package
with a fixed seed and design = "rcbd".
# Install the package if needed:
# install.packages("agricolae")
library(agricolae)
set.seed(2026)
trt <- c(2, 2, 2)
outdesign <- design.ab(
trt = trt,
r = 3,
serie = 2,
design = "rcbd",
seed = 2026,
kinds = "Super-Duper",
first = TRUE,
randomization = TRUE
)
book <- outdesign$book
# Rename factor columns to the study's factor names
names(book)[names(book) == "A"] <- "Fertilizer"
names(book)[names(book) == "B"] <- "Irrigation"
names(book)[names(book) == "C"] <- "Temperature"
book
## plots block Fertilizer Irrigation Temperature
## 1 101 1 1 1 1
## 2 102 1 1 1 2
## 3 103 1 1 2 2
## 4 104 1 2 1 1
## 5 105 1 1 2 1
## 6 106 1 2 1 2
## 7 107 1 2 2 1
## 8 108 1 2 2 2
## 9 109 2 2 1 1
## 10 110 2 1 1 1
## 11 111 2 1 2 1
## 12 112 2 2 2 1
## 13 113 2 1 2 2
## 14 114 2 1 1 2
## 15 115 2 2 1 2
## 16 116 2 2 2 2
## 17 117 3 1 1 2
## 18 118 3 2 1 1
## 19 119 3 2 2 1
## 20 120 3 1 1 1
## 21 121 3 1 2 2
## 22 122 3 2 1 2
## 23 123 3 2 2 2
## 24 124 3 1 2 1
The book output is the randomized field layout. Each
block contains all eight factorial treatment combinations. The seed
value (2026) makes the randomized layout reproducible.