#data
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)

#1a

Model: Y = μ + A + B + C + AB + AC + BC + ABC + ε

Where: - Y = density - μ = mean - A = Ammonium - B = Stir Rate - C = Temperature - AB, AC, BC = interactions - ABC = three-way interaction - ε = error


#1b

# Fit model
model <- aov(Density ~ factor(Ammonium) * factor(StirRate) * factor(Temperature))
summary(model)
##                                                       Df Sum Sq Mean Sq F value
## factor(Ammonium)                                       1  44.39   44.39  11.180
## factor(StirRate)                                       1  70.69   70.69  17.804
## factor(Temperature)                                    1   0.33    0.33   0.083
## factor(Ammonium):factor(StirRate)                      1  28.12   28.12   7.082
## factor(Ammonium):factor(Temperature)                   1   0.02    0.02   0.005
## factor(StirRate):factor(Temperature)                   1  10.13   10.13   2.551
## factor(Ammonium):factor(StirRate):factor(Temperature)  1   1.52    1.52   0.383
## Residuals                                              8  31.76    3.97        
##                                                        Pr(>F)   
## factor(Ammonium)                                      0.01018 * 
## factor(StirRate)                                      0.00292 **
## factor(Temperature)                                   0.78117   
## factor(Ammonium):factor(StirRate)                     0.02875 * 
## factor(Ammonium):factor(Temperature)                  0.94281   
## factor(StirRate):factor(Temperature)                  0.14889   
## factor(Ammonium):factor(StirRate):factor(Temperature) 0.55341   
## Residuals                                                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Answer:

The factorial ANOVA results show that at α = 0.05, three effects are statistically significant. First, Ammonium has a significant main effect witch values of F = 11.180 and p = 0.01018) indicating that the amount of ammonium significantly affects density. Secondly, stir rate also has a significant effect , with values of F = 17.80 and p = 0.00292, that show stirring speed is an important factor in determining the density. Thirdly there is a significant two-way interaction between ammonium and stir rate , with values of F = 7.082 and p = 0.02875, meaning the effect of ammonium on density depends on the stir rate level.

#Problem 2

#data
Position <- c(1,1,1, 1,1,1, 1,1,1, 2,2,2, 2,2,2, 2,2,2)
Temperature <- c(800,800,800, 825,825,825, 850,850,850, 
                 800,800,800, 825,825,825, 850,850,850)
Density2 <- c(570,565,583, 1063,1080,1043, 565,510,590,
              528,547,521, 988,1026,1004, 526,538,532)

#2a

#fixed
model_a <- aov(Density2 ~ factor(Temperature) * factor(Position))
summary(model_a)
##                                      Df Sum Sq Mean Sq  F value   Pr(>F)    
## factor(Temperature)                   2 945342  472671 1056.117 3.25e-14 ***
## factor(Position)                      1   7160    7160   15.998  0.00176 ** 
## factor(Temperature):factor(Position)  2    818     409    0.914  0.42711    
## Residuals                            12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Answer:

When both temp. and position are treated as fixed effects, the ANOVA results show that temp has a highly significant effect on density with p < 0.001. position also has a significant effect with p = 0.00176. However, the temp. × Position interaction is not significant with p = 0.42711.Both main effects are significant but they do not interact.

#2b

#random
model_b <- aov(Density2 ~ Temperature + Position + Temperature:Position)
summary(model_b)
##                      Df Sum Sq Mean Sq F value Pr(>F)
## Temperature           1    234     234   0.003  0.954
## Position              1   7160    7160   0.105  0.750
## Temperature:Position  1    234     234   0.003  0.954
## Residuals            14 951063   67933

Answer:

When both temp. and position are treated as random effects, none of the effects are significant. temperature has p = 0.954, position has p = 0.750, and the temperature × position interaction has p = 0.954. This indicates that when we consider these factors as random samples from larger populations, there is no significant evidence that either factor affects density.

#2c

# Position fixed, temp random
model_c <- aov(Density2 ~ factor(Position) + Temperature + factor(Position):Temperature)
summary(model_c)
##                              Df Sum Sq Mean Sq F value Pr(>F)
## factor(Position)              1   7160    7160   0.105  0.750
## Temperature                   1    234     234   0.003  0.954
## factor(Position):Temperature  1    234     234   0.003  0.954
## Residuals                    14 951063   67933

Answer: When position is treated as fixed and temperature as random, none of the effects are significant. Position has p = 0.750 and temperature has p = 0.954, and the position × temperature interaction has p = 0.954. This mixed model shows results similar to part b, where treating temperature as random leads to no significant findings.

#2d

Answer: The three analyses reveal differences based on whether factors are treated as fixed or random effects. In part a with both factors fixed, both temperature and position were significant. However, in part b with both factors random, neither effect was significant. Part c with position fixed and temp. random showed no significant effects either. This demonstrates that treating factors as random versus fixed fundamentally changes the hypothesis being tested and the conclusions drawn.