\(y_{ijkl} = \mu + \tau_i + \beta_j + \gamma_k + (\tau\beta)_{ij} + (\tau\gamma)_{ik} + (\beta\gamma)_{jk} + (\tau\beta\gamma)_{ijk} + \varepsilon_{ijkl}\)
Where,
\(\tau_i = \text{Main Effect for Ammonium %}\)
\(\beta_j = \text{Main Effect for Stir Rate}\)
\(\gamma_k = \text{Main Effect for Temperature}\)
To identify which factors are significant, we use a step-by-step testing method. We start by checking if the three factors together have any significant interaction, and then move on to test the two-factor interactions.
library(GAD)
df<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")
print(df)
## 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
df$Ammonium<-as.fixed(df$Ammonium)
df$StirRate<-as.fixed(df$StirRate)
df$Temperature<-as.fixed(df$Temperature)
str(df)
## 'data.frame': 16 obs. of 4 variables:
## $ Ammonium : Factor w/ 2 levels "2","30": 1 1 2 2 1 1 2 2 1 1 ...
## $ StirRate : Factor w/ 2 levels "100","150": 1 1 1 1 2 2 2 2 1 1 ...
## $ Temperature: Factor w/ 2 levels "8","40": 1 1 1 1 1 1 1 1 2 2 ...
## $ Density : num 14.68 15.18 15.12 17.48 7.54 ...
Null Hypothesis:
\[ H_0 : (\tau \beta \gamma)_{ijk} = 0 \quad \forall \, i,j,k \]
Alternate Hypothesis:
\[ H_a : (\tau \beta \gamma)_{ijk} \neq 0 \quad \exists \, i,j,k \]
model<-aov(Density~Ammonium*StirRate*Temperature,data=df)
gad(model)
## $anova
## 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
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
The p value is greater than .o5, so we fail to reject null hypothesis and their is no interaction between 3 factors.
Null Hypothesis:
\[ H_0 : (\tau \gamma)_{ik} = 0 \quad \forall \, i,k \]
Alternate Hypothesis:
\[ H_a : (\tau \gamma)_{ik} \neq 0 \quad \exists \, i,k \]
model<-aov(Density~Ammonium*Temperature,data=df)
gad(model)
## $anova
## Analysis of Variance Table
##
## Response: Density
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.389 44.389 3.7456 0.07686 .
## Temperature 1 0.328 0.328 0.0277 0.87069
## Ammonium:Temperature 1 0.022 0.022 0.0018 0.96653
## Residuals 12 142.212 11.851
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ammonium 1 44.39 44.39 3.746 0.0769 .
## Temperature 1 0.33 0.33 0.028 0.8707
## Ammonium:Temperature 1 0.02 0.02 0.002 0.9665
## Residuals 12 142.21 11.85
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The p value is greater than .05, hense we fail to reject null hypothesis.
\[ H_0 : (\beta \gamma)_{jk} = 0 \quad \forall \, j,k \]
Alternate Hypothesis:
\[ H_a : (\beta \gamma)_{jk} \neq 0 \quad \exists \, j,k \]
model<-aov(Density~StirRate*Temperature,data=df)
gad(model)
## $anova
## Analysis of Variance Table
##
## Response: Density
## Df Sum Sq Mean Sq F value Pr(>F)
## StirRate 1 70.686 70.686 8.0167 0.01514 *
## Temperature 1 0.328 0.328 0.0372 0.85034
## StirRate:Temperature 1 10.128 10.128 1.1487 0.30491
## Residuals 12 105.809 8.817
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## StirRate 1 70.69 70.69 8.017 0.0151 *
## Temperature 1 0.33 0.33 0.037 0.8503
## StirRate:Temperature 1 10.13 10.13 1.149 0.3049
## Residuals 12 105.81 8.82
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The p valus is greater than .05, we fail to reject the null hypothesis.
\[ H_0 : (\tau \beta)_{ij} = 0 \quad \forall \, i,j \]
Alternate Hypothesis:
\[ H_a : (\tau \beta)_{ij} \neq 0 \quad \exists \, i,j \]
model<-aov(Density~Ammonium*StirRate,data=df)
gad(model)
## $anova
## 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
summary(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
The p value is less than .05, hense we reject null hypothesis.
interaction.plot(df$StirRate, df$Ammonium, df$Density, main = "Ammonium vs Stir Rate", ylab="Density")
since the lines are not parallel , the interaction between ammonium and StirRate is significant.
Null Hypothesis:
\[ H_0 : (\alpha \beta)_{ij} = 0 \quad \forall \, i,j \]
Alternate Hypothesis:
\[ H_a : (\alpha \beta)_{ij} \neq 0 \quad \exists \, i,j \] The data :
Position <- c(1, 2)
Temperature <- c(800, 825, 850)
df <- expand.grid(Position = Position, Temperature = Temperature)
df1 <- rbind(df, df, df)
# response
response <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
df1$response <- response
# Convert to factors for GAD
df1$Position <- as.fixed(df1$Position)
df1$Temperature <- as.fixed(df1$Temperature)
# Part A: Fixed effects
model1 <- aov(response ~ Position + Temperature + Position*Temperature, data = df1)
GAD::gad(model1)
## $anova
## Analysis of Variance Table
##
## Response: response
## Df Sum Sq Mean Sq F value Pr(>F)
## Position 1 1267 1267 1.7056 0.216
## Temperature 2 229965 114983 154.8241 2.696e-09 ***
## Position:Temperature 2 718547 359273 483.7613 3.381e-12 ***
## Residuals 12 8912 743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Part B: Random effects
df1$Position <- as.random(df1$Position)
df1$Temperature <- as.random(df1$Temperature)
model2 <- aov(response ~ Position + Temperature + Position*Temperature, data = df1)
GAD::gad(model2)
## $anova
## Analysis of Variance Table
##
## Response: response
## Df Sum Sq Mean Sq F value Pr(>F)
## Position 1 1267 1267 0.0035 0.9581
## Temperature 2 229965 114983 0.3200 0.7576
## Position:Temperature 2 718547 359273 483.7613 3.381e-12 ***
## Residuals 12 8912 743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Part C: Mixed effects
df1$Position <- as.fixed(df1$Position)
df1$Temperature <- as.random(df1$Temperature)
model3 <- aov(response ~ Position + Temperature + Position*Temperature, data = df1)
GAD::gad(model3)
## $anova
## Analysis of Variance Table
##
## Response: response
## Df Sum Sq Mean Sq F value Pr(>F)
## Position 1 1267 1267 0.0035 0.9581
## Temperature 2 229965 114983 154.8241 2.696e-09 ***
## Position:Temperature 2 718547 359273 483.7613 3.381e-12 ***
## Residuals 12 8912 743
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Comment:-
Across all three models, the interaction between Position and Temperature is highly significant, indicating a strong combined influence on the response. The main effect of Position is not significant in any case, suggesting it has little independent impact. When all factors are treated as fixed (Part A), Temperature shows a highly significant effect; however, when treated as random (Part B), its significance disappears because the variance is attributed to random variation. In the mixed model (Part C), Temperature regains significance, reflecting its consistent influence when properly tested against random variation.