Problem 1 a \[ y_{ijkl} = \mu + \alpha_i + \beta_j + \gamma_k + \alpha\beta_{ij} + \alpha\gamma_{ik} + \beta\gamma_{jk} + \alpha\beta\gamma_{ijk} + \epsilon_{ijkl} \]
b
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_1<-aov(dat$Density ~ dat$Ammonium + dat$StirRate + dat$Temperature
+ dat$Ammonium*dat$StirRate + dat$StirRate*dat$Temperature
+ dat$Ammonium*dat$Temperature+dat$Ammonium*dat$StirRate*dat$Temperature)
GAD::gad(model_1)
## $anova
## 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$StirRate:dat$Temperature 1 10.128 10.128 2.5510 0.148890
## dat$Ammonium:dat$Temperature 1 0.022 0.022 0.0055 0.942808
## dat$Ammonium:dat$StirRate:dat$Temperature 1 1.519 1.519 0.3826 0.553412
## Residuals 8 31.762 3.970
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p-value of dat\(Ammonium:dat\)StirRate is significant, as it is less than 0.05.
interaction.plot(dat$Ammonium, dat$StirRate, dat$Density)
Problem 2
pos <- c(rep("1",9),rep("2",9))
t <-c(800,825, 850)
temp<-rep(t, 6)
bd<-c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
dat2 <- data.frame(pos,temp,bd)
dat2$pos <- as.fixed(dat2$pos)
dat2$temp <- as.fixed(dat2$temp)
model21 <- aov(dat2$bd~dat2$temp+dat2$pos+dat2$temp*dat2$pos)
GAD::gad(model21)
## $anova
## Analysis of Variance Table
##
## Response: dat2$bd
## 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
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p-value: 3.25e-14, 0.001762, 0.427110 9 (temp, pos, interaction) b.
dat2$pos <- as.random(dat2$pos)
dat2$temp <- as.random(dat2$temp)
model22<- aov(dat2$bd~dat2$temp+dat2$pos+dat2$temp*dat2$pos)
GAD::gad(model22)
## $anova
## Analysis of Variance Table
##
## Response: dat2$bd
## 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
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p-value: 0.0008647, 0.0526583, 0.4271101 c.
dat2$pos <- as.fixed(dat2$pos)
dat2$temp <- as.random(dat2$temp)
model23 <- aov(dat2$bd~dat2$temp+dat2$pos+dat2$temp*dat2$pos)
GAD::gad(model23)
## $anova
## Analysis of Variance Table
##
## Response: dat2$bd
## 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
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p-value: 3.25e-14, 0.05266, 0.42711 d. From p-value, interaction in all cases are same, it is not significant. However, in main effect, p-value differs whether it is random or fixed.