Q1
# factors A with two levels (2,30)
Factor B Stir Rate with two levels (100,150)
Factor C Temperature with 2 levels (8,40)
a) Write the model equation for a full factorial model
Model equation
\(Y_{ijkl}=\mu+\alpha_{i}+\beta_{j}+\gamma_{k}+\alpha\beta_{ij}+\alpha\gamma_{ik}+\beta\gamma_{jk}+\alpha\beta\gamma_{ijk}+e_{ijkl}\)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
Dat<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/main/PowderProduction.csv")
colnames(Dat)<-c("A", "B", "C", "obs")
library(GAD)
## Loading required package: matrixStats
##
## Attaching package: 'matrixStats'
## The following object is masked from 'package:dplyr':
##
## count
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
Dat$A<-as.fixed(Dat$A)
Dat$B<-as.fixed(Dat$B)
Dat$C<-as.fixed(Dat$C)
Model<-aov(obs~A+B+C+A*B+A*C+B*C+A*B*C, data = Dat)
GAD::gad(Model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 44.389 44.389 11.1803 0.010175 *
## B 1 70.686 70.686 17.8037 0.002918 **
## C 1 0.328 0.328 0.0826 0.781170
## A:B 1 28.117 28.117 7.0817 0.028754 *
## A:C 1 0.022 0.022 0.0055 0.942808
## B:C 1 10.128 10.128 2.5510 0.148890
## A:B:C 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
With the p-value = 0.010175 we conclude factor A has a significant effect to improve a silver powder production process.
With the p-value = 0.002918 we conclude factor B has a significant effect to improve a silver powder production process.
With the p-value = 0.028754 we conclude the interaction between factors AB has a significant effect to improve a silver powder production. process.
Model after exclude insignificant factors
Model<-aov(obs~A+B+A*B, data = Dat)
GAD::gad(Model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 44.389 44.389 12.1727 0.0044721 **
## B 1 70.686 70.686 19.3841 0.0008612 ***
## A:B 1 28.117 28.117 7.7103 0.0167511 *
## Residual 12 43.759 3.647
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Q2
Factor A 2 levels, Factor B 3 levels n = 3 replications
Temp<-rep(seq(1,3), 3)
Temp
## [1] 1 2 3 1 2 3 1 2 3
Pos<-c(rep(1,9), rep(2,9))
Pos
## [1] 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2
obs1<-c(570, 1063, 565,
565, 1080, 510,
583, 1043, 590,
528, 988, 526,
547, 1026, 538,
521, 1004, 532)
Dat1<-data.frame(Pos,Temp,obs1)
Dat1$Temp<-as.fixed(Dat1$Temp)
Dat1$Pos<-as.fixed(Dat1$Pos)
Model2<-aov(obs1~Temp+Pos+Temp*Pos, data = Dat1)
GAD::gad(Model2)
## Analysis of Variance Table
##
## Response: obs1
## Df Sum Sq Mean Sq F value Pr(>F)
## Temp 2 945342 472671 1056.117 3.25e-14 ***
## Pos 1 7160 7160 15.998 0.001762 **
## Temp:Pos 2 818 409 0.914 0.427110
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
a) Assume that both Temperature and Position are fixed effects. Report p-values
Interaction Temp and Position., p-value = 0.427110.
Factor Temp p-value = 3.25e-14.
Factor Pos p-value = 0.001762.
Dat1$Temp<-as.random(Dat1$Temp)
Dat1$Pos<-as.random(Dat1$Pos)
Model3<-aov(obs1~Temp+Pos+Temp*Pos, data = Dat1)
GAD::gad(Model3)
## Analysis of Variance Table
##
## Response: obs1
## Df Sum Sq Mean Sq F value Pr(>F)
## Temp 2 945342 472671 1155.518 0.0008647 ***
## Pos 1 7160 7160 17.504 0.0526583 .
## Temp:Pos 2 818 409 0.914 0.4271101
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
b) Assume that both Temperature and Position are random effects. Report p-values
Interaction Temp and Position., p-value = 0.427110.
Factor Temp p-value = 0.0008647.
Factor Pos p-value = 0.0526583.
Dat1$Temp<-as.random(Dat1$Temp)
Dat1$Pos<-as.fixed(Dat1$Pos)
Model4<-aov(obs1~Temp+Pos+Temp*Pos, data = Dat1)
GAD::gad(Model4)
## Analysis of Variance Table
##
## Response: obs1
## Df Sum Sq Mean Sq F value Pr(>F)
## Temp 2 945342 472671 1056.117 3.25e-14 ***
## Pos 1 7160 7160 17.504 0.05266 .
## Temp:Pos 2 818 409 0.914 0.42711
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
c) Assume the Position effect is fixed and the Temperature effect is random. Report p-values
Interaction Temp and Position., p-value = 0.427110.
Factor Temp p-value = 3.25e-14.
Factor Pos p-value = 0.05266.
d) Comment on similarities and/or differences between the p-values in parts a,b,c.
The interaction between the factor Pos and Temp was not significant in all tests performed and has the same p-value for all conditions.
On the other hand, the factor Temp in part a (as fixed) resulted in the same p-value as part c (as.random). But in part b (both factors as.random) the p-value if factor Temp is bigger than parts a and b.
For the factor Pos, for parts b and c the p-value resulted is very close, but for part a was very small.