#16 part 1

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

#16a

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

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


#16b

#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
#interaction plots
interaction.plot(Ammonium, StirRate, Density)

interaction.plot(Ammonium, Temperature, Density)

interaction.plot(StirRate, Temperature, Density)

Answer:

At α = 0.05, the significant factors are Ammonium (p = 0.010), Stir Rate (p = 0.003), and the Ammonium×Stir Rate interaction (p = 0.029). Temperature is not significant (p = 0.781) and can be dropped. The Ammonium×Temperature interaction (p = 0.943), Stir Rate×Temperature interaction (p = 0.149), and the three-way interaction (p = 0.553) can all be dropped because their p-values are greater than 0.05. The Ammonium×Stir Rate interaction plot shows non-parallel lines, confirming this interaction is real.

#16 Part 2

library(agricolae)

#Factors
A <- c("Organic", "Chemical")
B <- c("Once", "Twice")
C <- c("22C", "28C")

#treatment combinations
treatments <- expand.grid(A = A, B = B, C = C)
treatments$treatment <- paste(treatments$A, treatments$B, treatments$C, sep = "-")

#treatment combinations
print(treatments)
##          A     B   C          treatment
## 1  Organic  Once 22C   Organic-Once-22C
## 2 Chemical  Once 22C  Chemical-Once-22C
## 3  Organic Twice 22C  Organic-Twice-22C
## 4 Chemical Twice 22C Chemical-Twice-22C
## 5  Organic  Once 28C   Organic-Once-28C
## 6 Chemical  Once 28C  Chemical-Once-28C
## 7  Organic Twice 28C  Organic-Twice-28C
## 8 Chemical Twice 28C Chemical-Twice-28C
#RCBD Design
design <- design.ab(
  trt = c(2, 2, 2),  # 2 levels for each of 3 factors
  r = 3,             # 3 replications
  serie = 2,
  design = "rcbd"
)

#display
print(design$book)
##    plots block A B C
## 1    101     1 1 2 1
## 2    102     1 1 1 1
## 3    103     1 2 2 1
## 4    104     1 1 1 2
## 5    105     1 2 1 1
## 6    106     1 1 2 2
## 7    107     1 2 1 2
## 8    108     1 2 2 2
## 9    109     2 2 2 2
## 10   110     2 1 2 1
## 11   111     2 2 1 2
## 12   112     2 1 1 2
## 13   113     2 2 2 1
## 14   114     2 1 2 2
## 15   115     2 1 1 1
## 16   116     2 2 1 1
## 17   117     3 2 1 2
## 18   118     3 2 1 1
## 19   119     3 1 2 1
## 20   120     3 1 1 2
## 21   121     3 2 2 2
## 22   122     3 1 2 2
## 23   123     3 2 2 1
## 24   124     3 1 1 1

Experimental Layout:

The design creates 8 treatment combinations (2³ = 8) arranged in 3 blocks (replications). Each block contains all 8 treatments in random order to control for variation between greenhouse benches.