1 Factorial Designs using R

1.1 Question 1

  1. An article in Quality Progress (May 2011, pp. 42–48) describes the use of factorial experiments to improve a silver powder production process. This product is used in conductive pastes to manufacture a wide variety of products ranging from silicon wafers to elastic membrane switches. We consider powder density (g/cm2)(g/cm2) as the response variable and critical characteristics of this product. The data is shown below.

Ammonium (%) Stir Rate (RPM) Temperature (°C) Density

2 100 8 14.68

2 100 8 15.18

30 100 8 15.12

30 100 8 17.48

2 150 8 7.54

2 150 8 6.66

30 150 8 12.46

30 150 8 12.62

2 100 40 10.95

2 100 40 17.68

30 100 40 12.65

30 100 40 15.96

2 150 40 8.03

2 150 40 8.84

30 150 40 14.96

30 150 40 14.96

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

b)     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.1 Solution 1a

Part a: 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}\)= Ammonium main Effect

\(\beta _{j}\) =Stir rate main effect

\(\gamma _{j}\)= Temperature Effect

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

1.1.2 Solution 1b

We need the hypothesis testing, and test 3 factor interaction will be our start point as we proceed to 2 factor interaction.

First we test the hypothesis for 3 factor interaction:

Null Hypothesis: \[H_{0}:(\tau\beta\gamma)_{jk}=0\forall "ijk"\]

Alternative Hypothesis:

\[ H_{a}: (\tau\beta\gamma)_{jk}\neq 0\exists "ijk" \]

Getting the data from Github

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
library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
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

We do not reject the Null hypothesis since the P value is greater than 0.05, with a value of 0.5534. Also, there is no three factor interaction

For the hypothesis for 2 Factor interaction starting with the highest P values: start with Ammonium and Temperature

Null Hypothesis: \[H_{0}:(\tau\gamma)_{ik}=0\forall "ik"\]

Alternative Hypothesis:

\[ H_{a}: (\tau\gamma)_{ik}\neq 0\exists "ik" \]

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

We have a P value of 0.904 for tau and gamma which is more than 0.05. As a result, we do not reject the Null hypothesis. Also, we can assume that Temperature and Ammonuim are not related.

Next we test for the next least significant two factor interaction:

Null Hypothesis: \[H_{0}:(\beta\gamma)_{jk}=0\forall "jk"\]

Alternative Hypothesis:

\[ H_{a}: (\beta\gamma)_{jk}\neq 0\exists "jk" \]

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

P value for Beta and Gamma = 0.1118

Since our P value is more than 0.005, we do no reject the Null hypothesis. Also, we can conclude that temperature and Stir rate has no relationship.

Next we test for Ammonium & StirRate, getting rid of stir rate and temperature:

Null Hypothesis: \[H_{0}:(\tau\beta)_{ij}=0\forall "ij"\]

Alternative Hypothesis:

\[ H_{a}: (\tau\beta)_{ij}\neq 0\exists "ij" \]

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

P value for tau and Beta= 0.219

Since our P value is less than 0,05, we do not reject the Null hypothesis. As a result, we can conclude that Ammonium and Stir Rate are related.

Plotting the Interaction Graph:

interaction.plot(csvData$StirRate,csvData$Ammonium,csvData$Density,col=c("green","orange"))

The plot implies a significant interaction between ammonium and stir rate since the lines are not parallel.

1.2 Question 2

1.       A full factorial experiment was conducted to determine whether either firing temperature or furnace position affects the baked density of a carbon anode.

Temperature (°C)

Position 800 825 850 1 570 1063 565 565 1080 510 583 1043 590 2 528 988 526 547 1026 538 521 1004 532

a)      Assume that both Temperature and Position are fixed effects.  Report p-values

b)      Assume that both Temperature and Position are random effects.  Report p-values 

c)      Assume the Position effect is fixed and the Temperature effect is random.  Report p-values 

d)      Comment on similarities and/or differences between the p-values in parts a,b,c.   

1.2.1 Solution 2a

Null Hypothesis:

\[ H_{o}: (\alpha\beta)_{ij}\doteq 0\forall "ij" \]

Alternative Hypothesis:

\[ H_{a}: (\alpha\beta)_{ij}\neq 0\exists "ij" \]

Imputing 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.2.2 Part 1a: For 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

No two factor interaction is evident from the temperature and position with α=0.05

1.2.3 Part B: For 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

At α=0.05, no two factor interaction present, and the only temperature is important.

1.2.4 Part C: For Mixed Effect

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

Temperature proves significant at α=0.05 with no two factor interaction

1.2.5 Part D: Comments

a. The three effect model showed no significant relationship

b. All variables showed distinct temperature variables - for both fixed and random effects.

c. Temperature had a p-value which is similar for parts a & c. It, however, increased in the second part since there was a random temperature.

d. Finally, we had a position variable with significant effect when fixed for the first part, and the temperature has a fixed effect which is different for a random effect.

2 Complete R Code

#Question 1
#Reading the data

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)

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)

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

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

#plotting the graph
interaction.plot(csvData$StirRate,csvData$Ammonium,csvData$Density,col=c("green","orange"))


#Question 2

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

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

#part b: For Random Effects 

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

#Part C: For Mixed Effect 

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