Model equation:
\[ y_{ijkl} = \mu + \alpha_i + \beta_j + \gamma_k + \alpha\beta_{ij} + \alpha\gamma_{ik} + \beta\gamma_{jk} + \alpha\beta\gamma_{ijk} + e_{ijkl} \]
ANOVA:
dat_silver <- 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)
)
dat_silver$ammonium <- as.factor(dat_silver$ammonium)
dat_silver$stirrate <- as.factor(dat_silver$stirrate)
dat_silver$temperature <- as.factor(dat_silver$temperature)
silver <- aov( density ~ ammonium * stirrate * temperature, data = dat_silver)
summary(silver)
## 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
At a significance level of 0.05, ammonium (p = 0.01018), stir rate (p = 0.00292), and the interaction between ammonium and stir rate (p = 0.02875) are statistically significant. Temperature and the remaining interaction effects are not statistically significant. The significant interaction indicates that the effect of ammonium on mean density depends on the stir rate. Therefore, the interaction between ammonium and stir rate should be considered when interpreting their effects on density.
interaction.plot(
x.factor = dat_silver$stirrate,
trace.factor = dat_silver$ammonium,
response = dat_silver$density,
xlab = "Stir Rate",
ylab = "Mean Density",
trace.label = "Ammonium"
)
Model equation:
\[ y_{ijk} = \mu + \alpha_i + \beta_j + \alpha\beta_{ij} + e_{ijk} \]
ANOVA (Assume that both Temperature and Position are fixed effects)
library(GAD)
dat_carbon <- data.frame(
position = factor(rep(1:2, each = 9)),
temperature = factor(rep(rep(c(800, 825, 850), each = 3), 2)),
density = c(
570, 565, 583,
1063, 1080, 1043,
565, 510, 590,
528, 547, 521,
988, 1026, 1004,
526, 538, 532
)
)
dat_carbon$position <- as.fixed(dat_carbon$position)
dat_carbon$temperature <- as.fixed(dat_carbon$temperature)
carbon_fe <- aov(density ~ position * temperature, data = dat_carbon)
gad(carbon_fe)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## position 1 7160 7160 15.998 0.001762 **
## temperature 2 945342 472671 1056.117 3.25e-14 ***
## position:temperature 2 818 409 0.914 0.427110
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
At a significance level of 0.05, both temperature (p < 0.0001) and position (p = 0.0018) have statistically significant effects on the baked density of carbon anodes. However, their interaction (p = 0.4271) is not significant. Therefore, both temperature and position independently affect the mean baked density, with no significant evidence of interaction.
ANOVA (Assume that both Temperature and Position are random effects)
library(GAD)
dat_carbon <- data.frame(
position = factor(rep(1:2, each = 9)),
temperature = factor(rep(rep(c(800, 825, 850), each = 3), 2)),
density = c(
570, 565, 583,
1063, 1080, 1043,
565, 510, 590,
528, 547, 521,
988, 1026, 1004,
526, 538, 532
)
)
dat_carbon$position <- as.random(dat_carbon$position)
dat_carbon$temperature <- as.random(dat_carbon$temperature)
carbon_re <- aov(density ~ position * temperature, data = dat_carbon)
gad(carbon_re)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## position 1 7160 7160 17.504 0.0526583 .
## temperature 2 945342 472671 1155.518 0.0008647 ***
## position:temperature 2 818 409 0.914 0.4271101
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
At a significance level of 0.05, temperature (p = 0.000865) is statistically significant, while position (p = 0.0527) and their interaction (p = 0.4271) are not significant. Therefore, there is evidence of variation in baked density due to temperature, but insufficient evidence of variation due to position or the interaction.
ANOVA (Assume the Position effect is fixed and the Temperature effect is random)
library(GAD)
dat_carbon <- data.frame(
position = factor(rep(1:2, each = 9)),
temperature = factor(rep(rep(c(800, 825, 850), each = 3), 2)),
density = c(
570, 565, 583,
1063, 1080, 1043,
565, 510, 590,
528, 547, 521,
988, 1026, 1004,
526, 538, 532
)
)
dat_carbon$position <- as.fixed(dat_carbon$position)
dat_carbon$temperature <- as.random(dat_carbon$temperature)
carbon_fre <- aov(density ~ position * temperature, data = dat_carbon)
gad(carbon_fre)
## $anova
## Analysis of Variance Table
##
## Response: density
## Df Sum Sq Mean Sq F value Pr(>F)
## position 1 7160 7160 17.504 0.05266 .
## temperature 2 945342 472671 1056.117 3.25e-14 ***
## position:temperature 2 818 409 0.914 0.42711
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
At a significance level of 0.05, temperature (p = 0.000865) is statistically significant, while position (p = 0.0527) and their interaction (p = 0.4271) are not significant. Therefore, temperature contributes significantly to variation in baked density, while there is insufficient evidence that position affects the mean baked density.
Comment:
The results show that temperature is statistically significant in all three models, while the interaction between temperature and position is not significant in any model. However, the significance of position changes depending on the model. When both factors are fixed, position is significant (p = 0.0018). When both factors are random, or when position is fixed and temperature is random, position is no longer significant (p = 0.0527). This difference occurs because the F-tests use different error terms depending on whether the factors are fixed or random. Therefore, the choice of fixed or random effects can influence the conclusions of the ANOVA.