Importing Data
library(readxl)
ING <- read_excel("D:/COLLEGE 4TH YEAR/1st SEMESTER/STAT 55 EXPERIMENTAL DESIGN/FINAL/FINAL EXAM - DATA FOR FIVE DIFFERENT INGREDIENTS (DUHAYLUNGSOD_BS MATH-STAT 4).xlsx")
ING
Verify the Variables Structure
str(ING)
tibble [25 × 4] (S3: tbl_df/tbl/data.frame)
$ Batch : num [1:25] 1 1 1 1 1 2 2 2 2 2 ...
$ Day : num [1:25] 1 2 3 4 5 1 2 3 4 5 ...
$ Ingredients: chr [1:25] "A" "B" "D" "C" ...
$ Hours : num [1:25] 8 7 1 7 3 11 2 7 3 8 ...
Changing Variables Structure into Factors
ING$Batch <- as.factor(ING$Batch)
ING$Day <- as.factor(ING$Day)
ING$Ingredients <- as.factor(ING$Ingredients)
str(ING)
tibble [25 × 4] (S3: tbl_df/tbl/data.frame)
$ 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 ...
$ Ingredients: Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
$ Hours : num [1:25] 8 7 1 7 3 11 2 7 3 8 ...
attach(ING)
Applying Analysis of Variance Model
model <- lm(Hours ~ Batch+Day+Ingredients)
anova(model)
Analysis of Variance Table
Response: Hours
Df Sum Sq Mean Sq F value Pr(>F)
Batch 4 15.44 3.860 1.2345 0.3476182
Day 4 12.24 3.060 0.9787 0.4550143
Ingredients 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
Mean Comparison Test
library(agricolae)
# LSD test
LSD.test(y = model,
trt = "Ingredients",
DFerror = model$df.residual,
MSerror = deviance(model)/model$df.residual,
alpha = 0.05,
group = TRUE,
console = TRUE)
Study: model ~ "Ingredients"
LSD t Test for Hours
Mean Square Error: 3.126667
Ingredients, means and individual ( 95 %) CI
Hours std r LCL UCL Min Max
A 8.4 1.140175 5 6.677038 10.122962 7 10
B 5.6 2.073644 5 3.877038 7.322962 3 8
C 8.8 1.643168 5 7.077038 10.522962 7 11
D 3.4 2.073644 5 1.677038 5.122962 1 6
E 3.2 1.923538 5 1.477038 4.922962 1 6
Alpha: 0.05 ; DF Error: 12
Critical Value of t: 2.178813
least Significant Difference: 2.436636
Treatments with the same letter are not significantly different.
Hours groups
C 8.8 a
A 8.4 a
B 5.6 b
D 3.4 b
E 3.2 b
# SNK test
SNK.test(y = Hours,
trt = Ingredients,
DFerror = model$df.residual,
MSerror = deviance(model)/model$df.residual,
alpha = 0.05,
group = TRUE,
console = TRUE)
Study: Hours ~ Ingredients
Student Newman Keuls Test
for Hours
Mean Square Error: 3.126667
Ingredients, means
Hours std r Min Max
A 8.4 1.140175 5 7 10
B 5.6 2.073644 5 3 8
C 8.8 1.643168 5 7 11
D 3.4 2.073644 5 1 6
E 3.2 1.923538 5 1 6
Alpha: 0.05 ; DF Error: 12
Critical Range
2 3 4 5
2.436636 2.983558 3.320217 3.564608
Means with the same letter are not significantly different.
Hours groups
C 8.8 a
A 8.4 a
B 5.6 b
D 3.4 b
E 3.2 b