chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
bolts <- c(rep(seq(1,5),4))
obs <- c(73,68,74,71,67,73,67,75,72,70,75,68,78,73,68,73,71,75,75,69)
chemical <- as.fixed(chemical)
bolts <- as.fixed(bolts)
model1 <- lm(obs~chemical+bolts)
gad(model1)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## chemical 3 12.95 4.317 2.3761 0.1211
## bolts 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
tau_1 <- mean(obs[1:5])-mean(obs)
tau_1
## [1] -1.15
tau_2 <- mean(obs[6:10])-mean(obs)
tau_2
## [1] -0.35
tau_3 <- mean(obs[11:15])-mean(obs)
tau_3
## [1] 0.65
tau_4 <- mean(obs[16:20])-mean(obs)
tau_4
## [1] 0.85
beta_1 <- mean(c(73,73,75,73))-mean(obs)
beta_1
## [1] 1.75
beta_2 <- mean(c(68,67,68,71))-mean(obs)
beta_2
## [1] -3.25
beta_3 <- mean(c(74,75,78,75))-mean(obs)
beta_3
## [1] 3.75
beta_4 <- mean(c(71,72,73,75))-mean(obs)
beta_4
## [1] 1
beta_5 <- mean(c(67,70,68,69))-mean(obs)
beta_5
## [1] -3.25
batch <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5))
Day <- c(rep(seq(1,5),5))
ingred <- c("A","B","D","C","E","C","E","A","D","B","B","A","C","E","D","D","C","E","B","A","E","D","B","A","C")
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)
dat <- cbind(batch,Day,ingred,obs)
dat <- as.data.frame(dat)
dat$batch <- as.fixed(dat$batch)
dat$Day <- as.fixed(dat$Day)
dat$ingred <- as.fixed(dat$ingred)
model3 <- lm(dat$obs~dat$batch+dat$Day+dat$ingred,data = dat)
anova(model3)
## Analysis of Variance Table
##
## Response: dat$obs
## Df Sum Sq Mean Sq F value Pr(>F)
## dat$batch 4 15.44 3.860 1.2345 0.3476182
## dat$Day 4 12.24 3.060 0.9787 0.4550143
## dat$ingred 4 141.44 35.360 11.3092 0.0004877 ***
## Residuals 12 37.52 3.127
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1