##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,64,68,88,104,60,73,92,96,92,98,99,104,86,104,108,110,88,88,95,99,99,104,108,114,98,99,110,111,102,95,99,107)
fr <- c(rep(1,12),rep(2,12),rep(3,12))
doct <- rep(seq(1,4),9)
fr <- as.fixed(fr)
doct <- as.fixed(doct)
model <- aov(observation~fr+doct+fr*doct)
GAD::gad(model)
## Analysis of Variance Table
##
## Response: observation
## Df Sum Sq Mean Sq F value Pr(>F)
## fr 2 3160.50 1580.25 55.0184 1.086e-09 ***
## doct 3 2125.11 708.37 24.6628 1.652e-07 ***
## fr:doct 6 557.06 92.84 3.2324 0.01797 *
## Residual 24 689.33 28.72
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
###As p-value is less than the value of alpha. Therefore we reject Ho and say there is adifference in means.
plot(model)




### data has unequal variance.
### data are normal distributed.
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)
pe1<- mean(block1)
pe2<- mean(block2)
pe3 <- mean(block3)
# p value (fr) = 1.086e-09
# (doct) = 1.652e-07
# (Fr:doct) = 0.01797