# q 5.34
##Xijkl=mu+alpha i+beta j+gamma k+ alpha beta ij+alpha gamma ik+ beta gamma jk+alpha beta gamma ijk+epsilonijk
### (H0): (alpha)i = 0 for all i
### (Ha): (alpha)i != 0 for some i
### (H0): (beta)j = 0 for all j
### (Ha): (beta)j != 0 for some j
### (H0): (alpha)_ix(beta)j = 0 for all i&j
### (Ha): (alpha)_ix(beta)j != 0 for some i&j
library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
observation <- c(74,79,82,99,92,98,99,104,99,104,108,114,64,68,88,104,86,104,108,110,98,99,110,111,60,73,92,96,88,88,95,99,102,95,99,107)
b <- c(rep(1,12),rep(2,12),rep(3,12))
fr <- c(rep(0.20,4),rep(0.25,4),rep(0.30,4))
fr <- rep(fr,3)
doct <- rep(seq(1,4),9)
b <- as.fixed(b)
fr <- as.fixed(fr)
doct <- as.fixed(doct)
exp <- lm(observation~b+fr*doct)
gad(exp)
## Analysis of Variance Table
##
## Response: observation
## Df Sum Sq Mean Sq F value Pr(>F)
## b 2 180.67 90.33 3.9069 0.035322 *
## fr 2 3160.50 1580.25 68.3463 3.635e-10 ***
## doct 3 2125.11 708.37 30.6373 4.893e-08 ***
## fr:doct 6 557.06 92.84 4.0155 0.007258 **
## Residual 22 508.67 23.12
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(exp)




block1 <- c(74,79,82,99,92,98,99,104,99,104,108,114)
block2 <- c(64,68,88,104,86,104,108,110,98,99,110,111)
block3 <- c(60,73,92,96,88,88,95,99,102,95,99,107)
b1 <- var(block1)
b2 <- var(block2)
b3 <- var(block3)
### the value of the varience of block 1,2,3 are not equal and differs a lot and makes expriement useless.