1 Question 1:

The data may be downloaded from here: https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv

Assume Ammonium, Stir Rate, and Temperature are factors with fixed effects, each with two levels, and the design is replicated twice. 

a)Write the model equation for a full factorial model

  1. What factors are deemed significant, using a=.05 as a guide.  Report final p-values of significant factors (and interaction plots if necessary).

1.1 Solution:

Part A:

Full Factorial Model Equation:

\[ y_{ijk}=\mu+\tau_{i}+\beta_{j}+\gamma_{k}+(\tau\beta)_{ij}+(\tau\gamma)_{ik}+(\beta\gamma)_{jk}+(\tau\beta\gamma)_{ijk}+\epsilon_{ijkl} \]

Where,

\(\tau_{i}\)=Main Effect for Ammonium %

\(\beta_{j}\)=Main Effect for Stir Rate

\(\gamma_{k}\)=Main Effect for Temperature

i = 2,30 denoting two levels of ammonium
j = 100,150 denoting two levels of stir rate
k= 8,40 denoting two levels of temperature
l= 2 replicates

PART B:

To identify which factors are significant we perform an iterative approach i.e. perform hypothesis testing starting from testing for 3 factor interactions to testing for 2 factor interactions.

Starting with testing hypothesis for 3 Factor interaction:

Null: \[H_o:(\tau\beta\gamma)_{ijk}=0\space\forall\space"ijk"\]Alternate:\[H_a: (\tau\beta\gamma)_{ijk}\neq0\space\exists\space"ijk"\]Reading the data:

csvData <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")
print(csvData)
##    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

Ammonium, Stir Rate, and Temperature are factors with fixed effects, each with two levels, and the design is replicated twice.

library(GAD)
csvData$Ammonium <- as.fixed(csvData$Ammonium)
csvData$StirRate <- as.fixed(csvData$StirRate)
csvData$Temperature <- as.fixed(csvData$Temperature)
str(csvData)
## 'data.frame':    16 obs. of  4 variables:
##  $ Ammonium   : Factor w/ 2 levels "2","30": 1 1 2 2 1 1 2 2 1 1 ...
##  $ StirRate   : Factor w/ 2 levels "100","150": 1 1 1 1 2 2 2 2 1 1 ...
##  $ Temperature: Factor w/ 2 levels "8","40": 1 1 1 1 1 1 1 1 2 2 ...
##  $ Density    : num  14.68 15.18 15.12 17.48 7.54 ...
model<-aov(csvData$Density~csvData$Ammonium+csvData$StirRate+csvData$Temperature+csvData$Ammonium*csvData$StirRate+
             csvData$Ammonium*csvData$Temperature+csvData$StirRate*csvData$Temperature+
             csvData$Ammonium*csvData$StirRate*csvData$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: csvData$Density
##                                                       Df Sum Sq Mean Sq F value
## csvData$Ammonium                                       1 44.389  44.389 11.1803
## csvData$StirRate                                       1 70.686  70.686 17.8037
## csvData$Temperature                                    1  0.328   0.328  0.0826
## csvData$Ammonium:csvData$StirRate                      1 28.117  28.117  7.0817
## csvData$Ammonium:csvData$Temperature                   1  0.022   0.022  0.0055
## csvData$StirRate:csvData$Temperature                   1 10.128  10.128  2.5510
## csvData$Ammonium:csvData$StirRate:csvData$Temperature  1  1.519   1.519  0.3826
## Residual                                               8 31.762   3.970        
##                                                         Pr(>F)   
## csvData$Ammonium                                      0.010175 * 
## csvData$StirRate                                      0.002918 **
## csvData$Temperature                                   0.781170   
## csvData$Ammonium:csvData$StirRate                     0.028754 * 
## csvData$Ammonium:csvData$Temperature                  0.942808   
## csvData$StirRate:csvData$Temperature                  0.148890   
## csvData$Ammonium:csvData$StirRate:csvData$Temperature 0.553412   
## Residual                                                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
—> The three factor interaction p value (0.5534) is greater than 0.05 , hence we fail to reject Null Hypothesis , and claim that there is no three factor interaction present.

Now Performing hypothesis for 2 Factor interactions one by one with highest p-values first (Remember since 3 factor interaction is already performed we will eliminate that from our model equation)

Performing Hypothesis for 2 factor interaction between Ammonium (\(\tau_{i}\)) and Temperature (\(\gamma_{k}\)):

Null:\[H_0:(\tau\gamma)_{ik}=0\space\forall\space"i,k"\]

Alternate:\[H_a:(\tau\gamma)_{ik}\neq0\space\exists"i,k"\]

model<-aov(csvData$Density~csvData$Ammonium+csvData$StirRate+csvData$Temperature+csvData$Ammonium*csvData$StirRate+
             csvData$Ammonium*csvData$Temperature+csvData$StirRate*csvData$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: csvData$Density
##                                      Df Sum Sq Mean Sq F value   Pr(>F)   
## csvData$Ammonium                      1 44.389  44.389 12.0037 0.007109 **
## csvData$StirRate                      1 70.686  70.686 19.1150 0.001792 **
## csvData$Temperature                   1  0.328   0.328  0.0886 0.772681   
## csvData$Ammonium:csvData$StirRate     1 28.117  28.117  7.6033 0.022206 * 
## csvData$Ammonium:csvData$Temperature  1  0.022   0.022  0.0059 0.940538   
## csvData$StirRate:csvData$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
—> The p value for tau and gamma (0.940) is more than 0.05 , hence we fail to reject Null hypothesis and claim there is no interaction between Ammonium and Temperature.

Now eliminating (Ammonium & Temperature) two factor interaction from model equation and testing for the next least significant two factor interaction (P-Value=0.132) i.e. (Stir rate & Temperature) or we can say \((\beta\gamma)_{jk}\)

Null:\[H_o:(\beta\gamma)_{jk}=0\space\forall\space"j,k"\]

Alternate:\[H_a:(\beta\gamma)_{jk}\neq0\space\exists\space"j,k"\]

model<-aov(csvData$Density~csvData$Ammonium+csvData$StirRate+csvData$Temperature+csvData$Ammonium*csvData$StirRate+csvData$StirRate*csvData$Temperature)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: csvData$Density
##                                      Df Sum Sq Mean Sq F value    Pr(>F)    
## csvData$Ammonium                      1 44.389  44.389 13.3287 0.0044560 ** 
## csvData$StirRate                      1 70.686  70.686 21.2250 0.0009696 ***
## csvData$Temperature                   1  0.328   0.328  0.0984 0.7601850    
## csvData$Ammonium:csvData$StirRate     1 28.117  28.117  8.4426 0.0156821 *  
## csvData$StirRate:csvData$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
—> The p value for beta and gamma (0.111) is more than 0.05 , hence we fail to reject Null hypothesis and claim there is no interaction between Stir Rate and Temperature.

Now eliminating (StirRate & Temperature) two factor interaction from model equation and testing for the remaining two factor interaction i.e. (Ammonium & StirRate) or we can say \((\tau\beta)_{ij}\)

Null:\[H_o:(\tau\beta)_{ij}=0\space\forall\space"i,j"\]

Alternate:\[H_a:(\tau\beta)_{ij}\neq0\space\exists\space"i,j"\]

model<-aov(csvData$Density~csvData$Ammonium+csvData$StirRate+csvData$Temperature+csvData$Ammonium*csvData$StirRate)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: csvData$Density
##                                   Df Sum Sq Mean Sq F value   Pr(>F)   
## csvData$Ammonium                   1 44.389  44.389 11.2425 0.006443 **
## csvData$StirRate                   1 70.686  70.686 17.9028 0.001410 **
## csvData$Temperature                1  0.328   0.328  0.0830 0.778613   
## csvData$Ammonium:csvData$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
—> The p value for Tau & beta (0.0218) is less than 0.05 , hence we reject Null hypothesis and claim there is significant interaction between Ammonium & Stir rate. —> The Main Effects "Ammonium" and "StirRate" are also significant with P-values (0.00644) and (0.0014) both < 0.05 but since two factor interaction is significant it masks off the main effects and we do not consider

Plotting Interaction Graph for Ammonium and StirRate interaction:

interaction.plot(csvData$StirRate,csvData$Ammonium,csvData$Density,col=c("blue","red"))

—> Since the lines are not parallel, the interaction between ammonium and stir rate is significant.

2 Question 2:

2.1 Solution:

PART A:

Stating the Hypothesis:

NULL:\[H_o:(\alpha\beta)_{ij}=0\space\forall\space"i,j"\]

Alternate:

\[ H_a: (\alpha\beta)_{ij}\neq0\space\exists\space"i,j"\]

Reading the Data:

furnaceposition <- c(rep(1,9),rep(2,9))
temperatures<-c(800,825,850)
firingtemperature <- rep(temperatures,6)
bakeddensity <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
data.frame(furnaceposition,firingtemperature,bakeddensity)
##    furnaceposition firingtemperature bakeddensity
## 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
  1. Both Fixed Effects:
furnaceposition <- as.fixed(furnaceposition)
firingtemperature <- as.fixed(firingtemperature)
model_1 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_1)
## Analysis of Variance Table
## 
## Response: bakeddensity
##                                   Df Sum Sq Mean Sq  F value   Pr(>F)    
## furnaceposition                    1   7160    7160   15.998 0.001762 ** 
## firingtemperature                  2 945342  472671 1056.117 3.25e-14 ***
## furnaceposition:firingtemperature  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 that there is no two factor interaction present and position and temperature are significant at α=0.05
  1. Both Random Effects:
furnaceposition <- as.random(furnaceposition)
firingtemperature <- as.random(firingtemperature)
model_2 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_2)
## Analysis of Variance Table
## 
## Response: bakeddensity
##                                   Df Sum Sq Mean Sq  F value    Pr(>F)    
## furnaceposition                    1   7160    7160   17.504 0.0526583 .  
## firingtemperature                  2 945342  472671 1155.518 0.0008647 ***
## furnaceposition:firingtemperature  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 that there is no two factor interaction present and only temperature is significant at α=0.05
  1. Mixed Effects:
furnaceposition <- as.fixed(furnaceposition)
firingtemperature <- as.random(firingtemperature)
model_3 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_3)
## Analysis of Variance Table
## 
## Response: bakeddensity
##                                   Df Sum Sq Mean Sq  F value   Pr(>F)    
## furnaceposition                    1   7160    7160   17.504  0.05266 .  
## firingtemperature                  2 945342  472671 1056.117 3.25e-14 ***
## furnaceposition:firingtemperature  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 that there is no two factor interaction present and still only temperature is significant at α=0.05

PART D:

Comments:

—> 1:For all the three different effect models there was no significant two factor interaction. 2:The Temperature variable in all cases is significant, whether it was a random or fixed effect. 3:the p-value for Temperature is the same for parts a and c (in a Temperature is fixed, in c it is random), while it increases in part b (when Temperature is random). The same phenomenon occurs for Position, which has a similar p-value in parts b and c (in part b Position is random, in part c Position is fixed), while it is smaller in part a 4:The Position variable was significant when it was a fixed effect (part a) and the temperature is a fixed effect but not when it was a random effect nor when the temperature is a random effect.

3 SourceCode:

getwd()

#Question:1
#PARTA:(Write the model equation for a full factorial model)pg 222

#PARTB:
csvData <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")
print(csvData)

library(GAD)
csvData$Ammonium <- as.fixed(csvData$Ammonium)
csvData$StirRate <- as.fixed(csvData$StirRate)
csvData$Temperature <- as.fixed(csvData$Temperature)
str(csvData)

model<-aov(csvData$Density~csvData$Ammonium+csvData$StirRate+csvData$Temperature+csvData$Ammonium*csvData$StirRate+
             csvData$Ammonium*csvData$Temperature+csvData$StirRate*csvData$Temperature+
             csvData$Ammonium*csvData$StirRate*csvData$Temperature)
GAD::gad(model)

interaction.plot(csvData$StirRate,csvData$Ammonium,csvData$Density,col=c("blue","red"))


#Question:2 ()
furnaceposition <- c(rep(1,9),rep(2,9))
temperatures<-c(800,825,850)
firingtemperature <- rep(temperatures,6)
bakeddensity <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
data.frame(furnaceposition,firingtemperature,bakeddensity)

#PartA:(fixed effects)
furnaceposition <- as.fixed(furnaceposition)
firingtemperature <- as.fixed(firingtemperature)
model_1 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_1)


#PartB:(Random effects)
furnaceposition <- as.random(furnaceposition)
firingtemperature <- as.random(firingtemperature)
model_2 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_2)

#PartC:(Mixed Effect)
furnaceposition <- as.fixed(furnaceposition)
firingtemperature <- as.random(firingtemperature)
model_3 <- aov(bakeddensity~furnaceposition+firingtemperature+furnaceposition*firingtemperature)
GAD::gad(model_3)