Problem 1

(a)

The fixed-effects model is

\[Y_{ijkl}=\mu+\alpha_i+\beta_j+\gamma_k+(\alpha\beta)_{ij}+(\alpha\gamma)_{ik}+(\beta\gamma)_{jk}+(\alpha\beta\gamma)_{ijk}+\varepsilon_{ijkl},\]

where the errors are independent and normally distributed with mean zero and constant variance \(\sigma^2\).

(b) Full factorial ANOVA

powder <- data.frame(Ammonium = factor(c(2,2,30,30,2,2,30,30,2,2,30,30,2,2,30,30)),StirRate = factor(c(rep(100,4),rep(150,4),rep(100,4),rep(150,4))),Temperature = factor(c(rep(8,8),rep(40,8))),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

Since all factors are fixed, the standard ANOVA F-tests are appropriate.

powder_model <- aov(Density ~ Ammonium * StirRate * Temperature,data = powder)
summary(powder_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

At \(\alpha=0.05\), the significant terms are Ammonium (\(p=0.0102\)), Stir Rate (\(p=0.0029\)), and Ammonium:Stir Rate (\(p=0.0288\)). Temperature (\(p=0.7812\)), Ammonium:Temperature (\(p=0.9428\)), StirRate:Temperature (\(p=0.1489\)), and the three-way interaction (\(p=0.5534\)) are not significant.

Because the Ammonium:Stir Rate interaction is significant, the effect of changing stir rate depends on ammonium concentration. The following interaction plot averages over the two temperature level

with(powder,interaction.plot(x.factor=StirRate,trace.factor=Ammonium,response=Density,fun=mean, type="b", pch=c(16,17), lty=1:2,xlab="Stir Rate (RPM)",ylab="Mean Powder Density",trace.label="Ammonium (%)",main="Ammonium x Stir Rate Interaction"))

Conclusion: At the 5% significance level, ammonium concentration, stir rate, and their interaction significantly affect powder density.

Problem 2

Position has two levels, Temperature has three levels (800, 825, and 850 degrees C), and each combination has three observations.

The crossed factorial model is

\[Y_{ijk}=\mu+\alpha_i+\beta_j+(\alpha\beta)_{ij}+\varepsilon_{ijk}.\]

anode <- data.frame(Replicate = rep(1:3, times = 6),Temperature = factor(rep(c(800, 825, 850), each = 3, times = 2)),Position = factor(rep(c(1, 2), each = 9)),Density = c(570, 565, 583,1063, 1080, 1043,565, 510, 590,528, 547, 521,988, 1026, 1004,526, 538, 532))

anode
##    Replicate Temperature Position Density
## 1          1         800        1     570
## 2          2         800        1     565
## 3          3         800        1     583
## 4          1         825        1    1063
## 5          2         825        1    1080
## 6          3         825        1    1043
## 7          1         850        1     565
## 8          2         850        1     510
## 9          3         850        1     590
## 10         1         800        2     528
## 11         2         800        2     547
## 12         3         800        2     521
## 13         1         825        2     988
## 14         2         825        2    1026
## 15         3         825        2    1004
## 16         1         850        2     526
## 17         2         850        2     538
## 18         3         850        2     532

(a) Both Temperature and Position Are Fixed Effects

library(GAD)
Position <- as.fixed(anode$Position)
Temperature <- as.fixed(anode$Temperature)
model_fixed <- aov(anode$Density ~ Position * Temperature)

gad(model_fixed)
## $anova
## Analysis of Variance Table
## 
## Response: anode$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 \(\alpha = 0.05\), Position and Temperature are significant, while their interaction is not significant.

(b) Both Temperature and Position Are Random Effects

The random-effects model is:

\[Y_{ijk} = \mu + A_i + B_j + (AB)_{ij} + \varepsilon_{ijk}\]

Position <- as.random(anode$Position)
Temperature <- as.random(anode$Temperature)
model_random <- aov(anode$Density ~ Position * Temperature)

gad(model_random)
## $anova
## Analysis of Variance Table
## 
## Response: anode$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 \(\alpha = 0.05\), Temperature is significant, while Position and the interaction are not significant.

(c) Position Fixed and Temperature Random

In this mixed-effects model, Position is fixed and Temperature is random.

The model is:

\[Y_{ijk} = \mu + \alpha_i + B_j + (\alpha B)_{ij} + \varepsilon_{ijk}\]

Position <- as.fixed(anode$Position)
Temperature <- as.random(anode$Temperature)
model_mixed <- aov(anode$Density ~ Position * Temperature)

gad(model_mixed)
## $anova
## Analysis of Variance Table
## 
## Response: anode$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 \(\alpha = 0.05\), Temperature is significant, while Position and the interaction are not significant.

(d) Comparison of the Three Models

The p-values for the random-effects and mixed-effects models (b and c) are identical, while those for the fixed-effects model (a) differ because different error terms are used in the F-tests. Temperature is significant in all three models, whereas Position is significant only in the fixed-effects model. The interaction between Temperature and Position is not significant in any model at α = 0.05.

Complete R Code

library(GAD)

# Problem 1

Ammonium <- factor(c(2,2,30,30,2,2,30,30, 2,2,30,30,2,2,30,30))
StirRate <- factor(rep(c(100,150,100,150), each = 4))
Temperature <- factor(rep(c(8,40), each = 8))
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)

data1 <- data.frame(Ammonium, StirRate, Temperature, Density)
data1

# Question 1(b)

powder <- data.frame(Ammonium = factor(c(2,2,30,30,2,2,30,30,2,2,30,30,2,2,30,30)),StirRate = factor(c(rep(100,4),rep(150,4),rep(100,4),rep(150,4))),Temperature = factor(c(rep(8,8),rep(40,8))),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

model1 <- aov(Density ~ Ammonium * StirRate * Temperature)
summary(model1)

interaction.plot(StirRate, Ammonium, Density,fun = mean,type = "b",pch = c(16,17),lty = 1:2,xlab = "Stir Rate (RPM)",ylab = "Mean Powder Density",trace.label = "Ammonium (%)")


# Problem 2

Position <- factor(rep(c(1,2), each = 9))
Temperature <- factor(rep(c(800,825,850),each = 3, times = 2))
Density <- c(570,565,583,1063,1080,1043, 565,510,590,528,547,521,988,1026,1004,526,538,532)

data2 <- data.frame(Position, Temperature, Density)
data2

# Question 2(a)

Position <- as.fixed(data2$Position)
Temperature <- as.fixed(data2$Temperature)
model2a <- aov(Density ~ Position * Temperature)
gad(model2a)


# Question 2(b)

Position <- as.random(data2$Position)
Temperature <- as.random(data2$Temperature)
model2b <- aov(Density ~ Position * Temperature)
gad(model2b)

# Question 2(c)

Position <- as.fixed(data2$Position)
Temperature <- as.random(data2$Temperature)
model2c <- aov(Density ~ Position * Temperature)
gad(model2c)