Problem 1

\[ y_{ijk} = \mu + \alpha_i + \beta_j + \gamma_k + \alpha\beta_{ij} + \alpha\gamma_{ik} + \beta\gamma_{jk} + \alpha\beta\gamma_{ijk} + \epsilon_{ijk} \]

library(GAD)

dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")

dat$Ammonium<-as.fixed(dat$Ammonium)
dat$StirRate<-as.fixed(dat$StirRate)
dat$Temperature<-as.fixed(dat$Temperature)
model<-aov(dat$Density~dat$Ammonium+dat$StirRate+dat$Temperature+dat$Ammonium*dat$StirRate+dat$Ammonium*dat$Temperature+dat$StirRate*dat$Temperature+dat$Ammonium*dat$StirRate*dat$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: dat$Density
##                                           Df Sum Sq Mean Sq F value   Pr(>F)   
## dat$Ammonium                               1 44.389  44.389 11.1803 0.010175 * 
## dat$StirRate                               1 70.686  70.686 17.8037 0.002918 **
## dat$Temperature                            1  0.328   0.328  0.0826 0.781170   
## dat$Ammonium:dat$StirRate                  1 28.117  28.117  7.0817 0.028754 * 
## dat$Ammonium:dat$Temperature               1  0.022   0.022  0.0055 0.942808   
## dat$StirRate:dat$Temperature               1 10.128  10.128  2.5510 0.148890   
## dat$Ammonium:dat$StirRate:dat$Temperature  1  1.519   1.519  0.3826 0.553412   
## Residual                                   8 31.762   3.970                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Dropping the three factpr interaction we have
model<-aov(dat$Density~dat$Ammonium+dat$StirRate+dat$Temperature+dat$Ammonium*dat$StirRate+dat$Ammonium*dat$Temperature+dat$StirRate*dat$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: dat$Density
##                              Df Sum Sq Mean Sq F value   Pr(>F)   
## dat$Ammonium                  1 44.389  44.389 12.0037 0.007109 **
## dat$StirRate                  1 70.686  70.686 19.1150 0.001792 **
## dat$Temperature               1  0.328   0.328  0.0886 0.772681   
## dat$Ammonium:dat$StirRate     1 28.117  28.117  7.6033 0.022206 * 
## dat$Ammonium:dat$Temperature  1  0.022   0.022  0.0059 0.940538   
## dat$StirRate:dat$Temperature  1 10.128  10.128  2.7389 0.132317   
## Residual                      9 33.281   3.698                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Dropping the interaction between ammonium and temperature beacuse it is the most insignificant
model<-aov(dat$Density~dat$Ammonium+dat$StirRate+dat$Temperature+dat$Ammonium*dat$StirRate+dat$StirRate*dat$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: dat$Density
##                              Df Sum Sq Mean Sq F value    Pr(>F)    
## dat$Ammonium                  1 44.389  44.389 13.3287 0.0044560 ** 
## dat$StirRate                  1 70.686  70.686 21.2250 0.0009696 ***
## dat$Temperature               1  0.328   0.328  0.0984 0.7601850    
## dat$Ammonium:dat$StirRate     1 28.117  28.117  8.4426 0.0156821 *  
## dat$StirRate:dat$Temperature  1 10.128  10.128  3.0412 0.1117751    
## Residual                     10 33.303   3.330                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Dropping the interaction between Str rate and temperature beacuse it is the most insignificant
model<-aov(dat$Density~dat$Ammonium+dat$StirRate+dat$Temperature+dat$Ammonium*dat$StirRate)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: dat$Density
##                           Df Sum Sq Mean Sq F value   Pr(>F)   
## dat$Ammonium               1 44.389  44.389 11.2425 0.006443 **
## dat$StirRate               1 70.686  70.686 17.9028 0.001410 **
## dat$Temperature            1  0.328   0.328  0.0830 0.778613   
## dat$Ammonium:dat$StirRate  1 28.117  28.117  7.1211 0.021851 * 
## Residual                  11 43.431   3.948                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
interaction.plot(dat$StirRate,dat$Ammonium,dat$Density)

The factor that is significant it is between Ammonium and Stir Rate with a P-value of 0.021851 (<0.05). Based on this, we reject the Null hypothesis stating that the significant interaction between Ammonium and Stir Rate.

From the interaction plot we can see that with the Stir Rate of 100, there is not much difference in the density. However, when the Stir Rate increase to 150, there is a large difference in the density, Which explains the interaction between Ammonium and Stir Rate.

Problem 2

p<-c(rep(1,9),rep(2,9))
t<-c(800,825,850)
temp<-rep(t,6)
obs<-c(570,1063,565,
       565,1080,510,
       583,1043,590,
       528,988,526,
       547,1026,538,
       521,1004,532)
data.frame(p,temp,obs)
##    p temp  obs
## 1  1  800  570
## 2  1  825 1063
## 3  1  850  565
## 4  1  800  565
## 5  1  825 1080
## 6  1  850  510
## 7  1  800  583
## 8  1  825 1043
## 9  1  850  590
## 10 2  800  528
## 11 2  825  988
## 12 2  850  526
## 13 2  800  547
## 14 2  825 1026
## 15 2  850  538
## 16 2  800  521
## 17 2  825 1004
## 18 2  850  532

Item a)

temp<-as.fixed(temp)
p<-as.fixed(p)
model_2a<-aov(obs~p+temp+p*temp)
GAD::gad(model_2a)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value   Pr(>F)    
## p         1   7160    7160   15.998 0.001762 ** 
## temp      2 945342  472671 1056.117 3.25e-14 ***
## p:temp    2    818     409    0.914 0.427110    
## Residual 12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Item b)

temp<-as.random(temp)
p<-as.random(p)
model_2b<-aov(obs~p+temp+p*temp)
GAD::gad(model_2b)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value    Pr(>F)    
## p         1   7160    7160   17.504 0.0526583 .  
## temp      2 945342  472671 1155.518 0.0008647 ***
## p:temp    2    818     409    0.914 0.4271101    
## Residual 12   5371     448                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Item c)

temp<-as.random(temp)
p<-as.fixed(p)
model_2c<-aov(obs~p+temp+p*temp)
GAD::gad(model_2c)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value   Pr(>F)    
## p         1   7160    7160   17.504  0.05266 .  
## temp      2 945342  472671 1056.117 3.25e-14 ***
## p:temp    2    818     409    0.914  0.42711    
## Residual 12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the interaction P-values of position and Temperature, we are failing to reject the null hypothesis in all scenarios, because the P-value is greater than 0.05, which is our assumed reference alpha.

However, when looking at the main effects P-values, for item (a) we can see that both position and temperature are significant (P-valeus < 0.05). Similarly, for item b and c, both position and temperature are significant, but the position P-value is nearly 0.05 (0.05266).