chem1 <- c(73, 68, 74, 71, 67)
chem2 <- c(73, 67, 75, 72, 70)
chem3 <- c(75, 68, 78, 73, 68)
chem4 <- c(73, 71, 75, 75, 69)
dafr <- data.frame(chem1,chem2,chem3,chem4)
dafr <- stack(dafr)
colnames(dafr) <- c('Numbers','Type')
library(GAD)
dafr$Type <- as.fixed(dafr$Type)
dafr$Bolt <- c(rep(seq(1,5),4))
dafr$Bolt <- as.fixed(dafr$Bolt)
model <- lm(Numbers~Type+Bolt,dafr)
gad(model)
## Analysis of Variance Table
##
## Response: Numbers
## Df Sum Sq Mean Sq F value Pr(>F)
## Type 3 12.95 4.317 2.3761 0.1211
## Bolt 4 157.00 39.250 21.6055 2.059e-05 ***
## Residual 12 21.80 1.817
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Obs <- c(8,7,1,7,3,11,2,7,3,8,4,9,10,1,5,6,8,6,6,10,4,2,3,8,8)
Batch <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
Day <- c(rep(seq(1,5),5))
Ingredient <- c(1,2,4,3,5,3,5,1,4,2,2,1,3,5,4,4,3,5,2,1,5,4,2,1,3)
Batch <- as.factor(Batch)
Day <- as.factor(Day)
Ingredient <- as.factor(Ingredient)
Data <- data.frame(Obs, Batch, Day, Ingredient)
str(Data)
## 'data.frame': 25 obs. of 4 variables:
## $ Obs : num 8 7 1 7 3 11 2 7 3 8 ...
## $ Batch : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
## $ Day : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
## $ Ingredient: Factor w/ 5 levels "1","2","3","4",..: 1 2 4 3 5 3 5 1 4 2 ...
aov.model<-aov(Obs~Ingredient+Batch+Day,data=Data)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ingredient 4 141.44 35.36 11.309 0.000488 ***
## Batch 4 15.44 3.86 1.235 0.347618
## Day 4 12.24 3.06 0.979 0.455014
## Residuals 12 37.52 3.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1