library(readxl)
LSD_Exam <- read_excel("D:/MARV BS MATH/Marv 4th year, 1st sem/Regression Analysis/LSD Exam.xlsx")
LSD_Exam
# A tibble: 25 × 4
Batch Day Ingredients Hours
<dbl> <dbl> <chr> <dbl>
1 1 1 A 8
2 1 2 B 7
3 1 3 D 1
4 1 4 C 7
5 1 5 E 3
6 2 1 C 11
7 2 2 E 2
8 2 3 A 7
9 2 4 D 3
10 2 5 B 8
# … with 15 more rows
head(LSD_Exam)
# A tibble: 6 × 4
Batch Day Ingredients Hours
<dbl> <dbl> <chr> <dbl>
1 1 1 A 8
2 1 2 B 7
3 1 3 D 1
4 1 4 C 7
5 1 5 E 3
6 2 1 C 11
str(LSD_Exam)
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 ...
LSD_Exam$Batch <- as.factor(LSD_Exam$Batch)
LSD_Exam$Day <- as.factor(LSD_Exam$Day)
LSD_Exam$Ingredients <- as.factor(LSD_Exam$Ingredients)
str(LSD_Exam)
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(LSD_Exam)
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
The ingredient was significant i.e. reaction time of at least one ingredient is different from the rest. As ingredient is significant we should switch to multiple mean comparison test like LSD test.
library(agricolae)
Warning: package 'agricolae' was built under R version 4.2.2
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
The results showed that varieties C and A were statistically at par and reaction time of a chemical process significantly differ more than ingredients B, D and E.
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