FLIPPED ASSIGNMENT 12

Question 1.1 :

It is a valid latin square because it has two sources of nuisance variabiity which are the number of days and Batch effect. Also, the levels of the treatment A, B, C, D, E appear only once in every row and column. There is no interaction between any rows or columns. Therefore, ensuring orthogonality to the experiment.

Question 1.2 :

LINEAR MODEL EQUATION:

 \(y_{ijk}\) = \(\mu\) + \(\tau_i\) + \(\beta_{j}\) + \(\gamma_{k}\) + \(\varepsilon_{ijk}\)

Question 1.3 :

df<-expand.grid(seq(1,5),seq(1,5))
colnames(df)<-c("Day","Batch")
df$Day<-as.factor(df$Day)        
df$Batch<-as.factor(df$Batch)
str(df)
## 'data.frame':    25 obs. of  2 variables:
##  $ Day  : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
##  $ Batch: Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
##  - attr(*, "out.attrs")=List of 2
##   ..$ dim     : int [1:2] 5 5
##   ..$ dimnames:List of 2
##   .. ..$ Var1: chr [1:5] "Var1=1" "Var1=2" "Var1=3" "Var1=4" ...
##   .. ..$ Var2: chr [1:5] "Var2=1" "Var2=2" "Var2=3" "Var2=4" ...
df$Ingredient<-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")
df$Response<-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)
df$Ingredient<- as.factor(df$Ingredient)
str(df)
## 'data.frame':    25 obs. of  4 variables:
##  $ Day       : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
##  $ Batch     : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
##  $ Ingredient: Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
##  $ Response  : num  8 7 1 7 3 11 2 7 3 8 ...
##  - attr(*, "out.attrs")=List of 2
##   ..$ dim     : int [1:2] 5 5
##   ..$ dimnames:List of 2
##   .. ..$ Var1: chr [1:5] "Var1=1" "Var1=2" "Var1=3" "Var1=4" ...
##   .. ..$ Var2: chr [1:5] "Var2=1" "Var2=2" "Var2=3" "Var2=4" ...

Hypothesis:

Null Hypothesis:

\(H_0\) : \(\tau_i\) = 0

Alternate Hypothesis:

\(H_0\) : \(\tau_i\) \(\neq\) 0

aov.model <- aov(Response~Day+Batch+Ingredient,data=df)
summary(aov.model)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Day          4  12.24    3.06   0.979 0.455014    
## Batch        4  15.44    3.86   1.235 0.347618    
## Ingredient   4 141.44   35.36  11.309 0.000488 ***
## Residuals   12  37.52    3.13                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Conclusion: Since day has a p value of 0.455014, therefore it is not a significant factor for variability.

Since batch has a p value of 0.347618, therefore it is not a significant factor for variability.

Since ingredient has a p value of 0.000488 (less than significant value of 0.05, therefore it is a significant factor for variability. Therefore different ingredients have certain effect on reaction time of a process.

plot(aov.model)

COMPLETE CODE:

df<-expand.grid(seq(1,5),seq(1,5))
colnames(df)<-c("Day","Batch")
df$Day<-as.factor(df$Day)        
df$Batch<-as.factor(df$Batch)
str(df)
df$Ingredient<-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")
df$Response<-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)
df$Ingredient<- as.factor(df$Ingredient)
str(df)
aov.model <- aov(Response~Day+Batch+Ingredient,data=df)
summary(aov.model)
plot(aov.model)