data$ï..Ammonium <- as.fixed(data$ï..Ammonium)
data$StirRate<- as.fixed(data$StirRate)
data$Temperature <- as.fixed(data$Temperature)

Q1) a) Model Equation

\(Y_{ijkl}\) = \(\mu\) + \(\alpha_i\) + \(\beta_j\) + \(\gamma_k\)+ \(\alpha\beta_{ij}\) + \(\alpha\gamma_{ik}\) + \(\beta\gamma_{jk}\) + \(\alpha\beta\gamma_{ijk}\) + \(\epsilon_{ijkl}\)

Q2) b) Significance test

Hypothesis :

NUll Hypothesis : \(\alpha\beta\gamma_{ijk} = 0\) For all ijk

Alternative Hypothesis : \(\alpha\beta\gamma_{ijk} \neq 0\) for some ijk

model <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$ï..Ammonium*data$Temperature+data$StirRate*data$Temperature+data$ï..Ammonium*data$StirRate*data$Temperature,data=data)  

GAD::gad(model)
## Analysis of Variance Table
## 
## Response: data$Density
##                                                 Df Sum Sq Mean Sq F value
## data$ï..Ammonium                                 1 44.389  44.389 11.1803
## data$StirRate                                    1 70.686  70.686 17.8037
## data$Temperature                                 1  0.328   0.328  0.0826
## data$ï..Ammonium:data$StirRate                   1 28.117  28.117  7.0817
## data$ï..Ammonium:data$Temperature                1  0.022   0.022  0.0055
## data$StirRate:data$Temperature                   1 10.128  10.128  2.5510
## data$ï..Ammonium:data$StirRate:data$Temperature  1  1.519   1.519  0.3826
## Residual                                         8 31.762   3.970        
##                                                   Pr(>F)   
## data$ï..Ammonium                                0.010175 * 
## data$StirRate                                   0.002918 **
## data$Temperature                                0.781170   
## data$ï..Ammonium:data$StirRate                  0.028754 * 
## data$ï..Ammonium:data$Temperature               0.942808   
## data$StirRate:data$Temperature                  0.148890   
## data$ï..Ammonium:data$StirRate:data$Temperature 0.553412   
## Residual                                                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

As we can see our Three factor interaction p value is greater than 0.05 , hence we fail to reject NUll Hypothesis , and we claim that there is no three factor interaction presen t hence in next step lets discard three factor interaction from our model

lets test following hypothesis two factor hypothesis ,

We can see that alpha and gamma two factor interaction is the least significant from all other two factor interaction

Hypothesis :

NUll Hypothesis : \(\alpha\gamma_{ik}\) For all ik

Alternative Hypothesis : \(\alpha\gamma_{ik} \neq 0\) for some ik

model2 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$ï..Ammonium*data$Temperature+data$StirRate*data$Temperature,data=data)
GAD::gad(model2)
## Analysis of Variance Table
## 
## Response: data$Density
##                                   Df Sum Sq Mean Sq F value   Pr(>F)   
## data$ï..Ammonium                   1 44.389  44.389 12.0037 0.007109 **
## data$StirRate                      1 70.686  70.686 19.1150 0.001792 **
## data$Temperature                   1  0.328   0.328  0.0886 0.772681   
## data$ï..Ammonium:data$StirRate     1 28.117  28.117  7.6033 0.022206 * 
## data$ï..Ammonium:data$Temperature  1  0.022   0.022  0.0059 0.940538   
## data$StirRate:data$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

As we can see that p value for alpha and gamma is more than 0.05 , hence we fail to reject Null hypothesis and claim there is no interaction between alpha and gamma .

Hence lets remove it from our model and now run for the next least significant two factor interaction.

lets test following hypothesis two factor hypothesis ,

We can see that beta and gamma two factor interaction is the least significant from all other two factor interaction

Hypothesis :

NUll Hypothesis : \(\beta\gamma_{jk}\) For all jk

Alternative Hypothesis : \(\beta\gamma_{jk} \neq 0\) for some jk

model3 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$StirRate*data$Temperature,data=data)
GAD::gad(model3)
## Analysis of Variance Table
## 
## Response: data$Density
##                                Df Sum Sq Mean Sq F value    Pr(>F)    
## data$ï..Ammonium                1 44.389  44.389 13.3287 0.0044560 ** 
## data$StirRate                   1 70.686  70.686 21.2250 0.0009696 ***
## data$Temperature                1  0.328   0.328  0.0984 0.7601850    
## data$ï..Ammonium:data$StirRate  1 28.117  28.117  8.4426 0.0156821 *  
## data$StirRate:data$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

As we can see that p value for beta and gamma is more than 0.05 , hence we fail to reject Null hypothesis and claim there is no interaction between beta and gamma .

Hence lets remove it from our model and now run for the next least significant two factor interaction.

lets test following hypothesis two factor hypothesis ,

We can see that alpha and beta two factor interaction is the least significant from all other two factor interaction

Hypothesis :

NUll Hypothesis : \(\alpha\beta_{ij}\) For all ij

Alternative Hypothesis : \(\alpha\beta_{ij} \neq 0\) for some ij

model4 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate,data=data)
GAD::gad(model4)
## Analysis of Variance Table
## 
## Response: data$Density
##                                Df Sum Sq Mean Sq F value   Pr(>F)   
## data$ï..Ammonium                1 44.389  44.389 11.2425 0.006443 **
## data$StirRate                   1 70.686  70.686 17.9028 0.001410 **
## data$Temperature                1  0.328   0.328  0.0830 0.778613   
## data$ï..Ammonium:data$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

We can see from above test that for Ammonium and Stir Rate , p value is 0.021 < 0.05 . Hence we reject Null Hypothesis and claim that there is two factor interaction present between Ammonium and Stirrate .

interaction.plot(data$ï..Ammonium,data$StirRate,data$Density)

Q2)

pos <- c(rep("1",9),rep("2",9))
temp <- c("800","825","850","800","825","850","800","825","850","800","825","850","800","825","850","800","825","850") 
response <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
dat2 <- data.frame(pos,temp,response)

Q2a) Temp and pos are fixed effects

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

We can see from above test that ,

P value for Two factor interaction - 0.427

P value for Temp - 3.25e-14

P value for Pos - 0.001

we can see that there is no two factor interaction present

Q2b) Temp and pos are random effects

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

We can see from above test that ,

P value for Two factor interaction - 0.427

P value for Temp - 0.00086

P value for Pos - 0.052

we can see that there is no two factor interaction present

Q2c) Temp and pos are mixed effects , temp random and pos fixed

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

We can see from above test that ,

P value for Two factor interaction - 0.427

P value for Temp - 3.25e-14

P value for Pos - 0.0526

we can see that there is no two factor interaction present

Q2d) Comments

For all the three different effect models there was no significant two factor interaction.

For model with both factor as fixed :

Effect of Temperature and position were significant on the model .

For model with both factor as random :

Effect of Temperature is significant whereas the effect of position was nor significant on the model .

For mixed model with temp as random and pos as fixed :

Effect of Temperature is significant whereas the effect of position was nor significant on the model .

knitr::opts_chunk$set(echo = TRUE)
library(GAD)
data <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")
data$ï..Ammonium <- as.fixed(data$ï..Ammonium)
data$StirRate<- as.fixed(data$StirRate)
data$Temperature <- as.fixed(data$Temperature)
model <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$ï..Ammonium*data$Temperature+data$StirRate*data$Temperature+data$ï..Ammonium*data$StirRate*data$Temperature,data=data)  
GAD::gad(model)
model2 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$ï..Ammonium*data$Temperature+data$StirRate*data$Temperature,data=data)
GAD::gad(model2)
model3 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate+data$StirRate*data$Temperature,data=data)
GAD::gad(model3)
model4 <- aov(data$Density~data$ï..Ammonium+data$StirRate+data$Temperature+data$ï..Ammonium*data$StirRate,data=data)
GAD::gad(model4)
interaction.plot(data$ï..Ammonium,data$StirRate,data$Density)
pos <- c(rep("1",9),rep("2",9))
temp <- c("800","825","850","800","825","850","800","825","850","800","825","850","800","825","850","800","825","850") 
response <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
dat2 <- data.frame(pos,temp,response)
dat2$pos <- as.fixed(dat2$pos)
dat2$temp <- as.fixed(dat2$temp)
mod1 <- aov(dat2$response~dat2$temp+dat2$pos+dat2$temp*dat2$pos) 
GAD::gad(mod1)
dat2$pos <- as.random(dat2$pos)
dat2$temp <- as.random(dat2$temp)
mod2 <- aov(dat2$response~dat2$temp+dat2$pos+dat2$temp*dat2$pos) 
GAD::gad(mod2)
dat2$pos <- as.fixed(dat2$pos)
dat2$temp <- as.random(dat2$temp)
mod3 <- aov(dat2$response~dat2$temp+dat2$pos+dat2$temp*dat2$pos) 
GAD::gad(mod3)