Compare the efficiency of workers A, B, C and D using the given block x machine layout.
# Data transcribed from the image exactly as shown
# (Block I has A twice and no D in the provided table)
df <- data.frame(
Block = factor(rep(c("I", "II", "III", "IV", "V", "VI"), each = 4)),
Machine = factor(rep(c("M1", "M2", "M3", "M4"), times = 6)),
Worker = factor(c(
"C", "A", "B", "A",
"A", "B", "C", "D",
"A", "C", "D", "B",
"A", "D", "C", "B",
"B", "C", "A", "D",
"D", "C", "A", "B"
)),
Yield = c(
22, 14, 12, 23,
16, 18, 20, 25,
15, 23, 28, 14,
17, 21, 19, 11,
18, 20, 13, 24,
18, 21, 10, 17
)
)
df
## Block Machine Worker Yield
## 1 I M1 C 22
## 2 I M2 A 14
## 3 I M3 B 12
## 4 I M4 A 23
## 5 II M1 A 16
## 6 II M2 B 18
## 7 II M3 C 20
## 8 II M4 D 25
## 9 III M1 A 15
## 10 III M2 C 23
## 11 III M3 D 28
## 12 III M4 B 14
## 13 IV M1 A 17
## 14 IV M2 D 21
## 15 IV M3 C 19
## 16 IV M4 B 11
## 17 V M1 B 18
## 18 V M2 C 20
## 19 V M3 A 13
## 20 V M4 D 24
## 21 VI M1 D 18
## 22 VI M2 C 21
## 23 VI M3 A 10
## 24 VI M4 B 17
table(df$Block, df$Worker)
##
## A B C D
## I 2 1 1 0
## II 1 1 1 1
## III 1 1 1 1
## IV 1 1 1 1
## V 1 1 1 1
## VI 1 1 1 1
aggregate(Yield ~ Worker, data = df, FUN = mean)
## Worker Yield
## 1 A 15.42857
## 2 B 15.00000
## 3 C 20.83333
## 4 D 23.20000
# Compare reduced and full models to isolate worker effect
reduced <- lm(Yield ~ Block + Machine, data = df)
full <- lm(Yield ~ Block + Machine + Worker, data = df)
comparison <- anova(reduced, full)
comparison
## Analysis of Variance Table
##
## Model 1: Yield ~ Block + Machine
## Model 2: Yield ~ Block + Machine + Worker
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 15 431.13
## 2 12 145.64 3 285.48 7.8406 0.003672 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p_worker <- comparison[2, "Pr(>F)"]
if (p_worker < alpha) {
cat("Decision: Reject H0 at 5% significance level.\n")
cat("Conclusion: Worker efficiency differs significantly after adjusting for block and machine effects.")
} else {
cat("Decision: Fail to reject H0 at 5% significance level.\n")
cat("Conclusion: No significant worker-efficiency difference is detected after adjustment.")
}
## Decision: Reject H0 at 5% significance level.
## Conclusion: Worker efficiency differs significantly after adjusting for block and machine effects.