Let A be ammonium, B be stir rate, and C be temperature.
\[Y_{ijkl}=\mu+\alpha_i+\beta_j+\gamma_k +(\alpha\beta)_{ij}+(\alpha\gamma)_{ik}+(\beta\gamma)_{jk} +(\alpha\beta\gamma)_{ijk}+\epsilon_{ijkl}.\]
Here \(i,j,k=1,2\) and \(l=1,2\)
pwdr <- data.frame(
ammonium = factor(c(2, 2, 30,30, 2, 2, 30, 30,
2, 2, 30, 30, 2, 2, 30, 30)),
stir = factor(c(100, 100, 100, 100, 150, 150, 150, 150,
100, 100, 100, 100, 150, 150, 150, 150)),
temperature = factor(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)
)
full <- aov(density ~ ammonium *stir *temperature, data = pwdr)
summary(full)
## Df Sum Sq Mean Sq F value Pr(>F)
## ammonium 1 44.39 44.39 11.180 0.01018 *
## stir 1 70.69 70.69 17.804 0.00292 **
## temperature 1 0.33 0.33 0.083 0.78117
## ammonium:stir 1 28.12 28.12 7.082 0.02875 *
## ammonium:temperature 1 0.02 0.02 0.005 0.94281
## stir:temperature 1 10.13 10.13 2.551 0.14889
## ammonium:stir: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
At \(\alpha=0.05\), we find that ammonium, stir rate, and their interaction are significant.
step1 <- update(full, . ~ . - ammonium:stir:temperature)
step2 <- update(step1, . ~ . - ammonium:temperature)
step3 <- update(step2, . ~ . - stir:temperature)
final <- update(step3, . ~ . - temperature)
summary(final)
## Df Sum Sq Mean Sq F value Pr(>F)
## ammonium 1 44.39 44.39 12.17 0.004472 **
## stir 1 70.69 70.69 19.38 0.000861 ***
## ammonium:stir 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
The final model is \(Y=\mu+A+B+AB+\epsilon\).
Final p-values use the reduced model, with removed terms pooled into error.
interaction.plot(pwdr$stir, pwdr$ammonium, pwdr$density,
type = "b", col = c("blue", "red"),
xlab = "Stir rate (RPM)", ylab = "Mean density",
trace.label = "Ammonium (%)")
We find that higher stir rate reduces density more at 2% ammonium than at 30%. The effect of stir rate hence depends on the ammonium concentration.
carbon_anode <- data.frame(
position = c(1, 1, 1, 2, 2, 2,
1, 1, 1, 2, 2, 2,
1, 1, 1, 2, 2, 2),
temperature = c(800, 800, 800, 800, 800, 800,
825, 825, 825, 825, 825, 825,
850, 850, 850, 850, 850, 850),
density = c(570, 565, 583, 528, 547, 521,
1063, 1080, 1043, 988, 1026, 1004,
565, 510, 590, 526, 538, 532)
)
carbon_anode$temperature <- as.fixed(carbon_anode$temperature)
carbon_anode$position <- as.fixed(carbon_anode$position)
model_a <- aov(density ~ temperature * position, data = carbon_anode)
gad(model_a)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## temperature 2 945342 472671 1056.117 3.25e-14 ***
## position 1 7160 7160 15.998 0.001762 **
## temperature:position 2 818 409 0.914 0.427110
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
carbon_anode$temperature <- as.random(carbon_anode$temperature)
carbon_anode$position <- as.random(carbon_anode$position)
model_b <- aov(density ~ temperature * position, data = carbon_anode)
gad(model_b)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## temperature 2 945342 472671 1155.518 0.0008647 ***
## position 1 7160 7160 17.504 0.0526583 .
## temperature:position 2 818 409 0.914 0.4271101
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
carbon_anode$temperature <- as.random(carbon_anode$temperature)
carbon_anode$position <- as.fixed(carbon_anode$position)
model_c <- aov(density ~ temperature * position, data = carbon_anode)
gad(model_c)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## temperature 2 945342 472671 1056.117 3.25e-14 ***
## position 1 7160 7160 17.504 0.05266 .
## temperature:position 2 818 409 0.914 0.42711
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
We can infer that the temperature is significant in all three cases. Also, the position is significant only when both factors are fixed. The interaction is not significant in any case.
The p-values change as the F-test denominators change. We see that both fixed uses residual error for both main effects; both random uses the interaction, and the mixed model uses residual error for temperature and the interaction for position. The interaction test always uses residual error.