Compare the performance (tasks per minute) of trainees under four training programs using one-way ANOVA.
program_data <- list(
Program1 = c(9, 12, 14, 11, 13),
Program2 = c(10, 6, 9, 9, 10),
Program3 = c(12, 14, 11, 13, 11),
Program4 = c(9, 8, 11, 7, 8)
)
df <- stack(program_data)
names(df) <- c("Score", "Program")
df$Program <- factor(df$Program)
df
## Score Program
## 1 9 Program1
## 2 12 Program1
## 3 14 Program1
## 4 11 Program1
## 5 13 Program1
## 6 10 Program2
## 7 6 Program2
## 8 9 Program2
## 9 9 Program2
## 10 10 Program2
## 11 12 Program3
## 12 14 Program3
## 13 11 Program3
## 14 13 Program3
## 15 11 Program3
## 16 9 Program4
## 17 8 Program4
## 18 11 Program4
## 19 7 Program4
## 20 8 Program4
aggregate(Score ~ Program, data = df, FUN = mean)
## Program Score
## 1 Program1 11.8
## 2 Program2 8.8
## 3 Program3 12.2
## 4 Program4 8.6
fit <- aov(Score ~ Program, data = df)
anova_table <- summary(fit)
anova_table
## Df Sum Sq Mean Sq F value Pr(>F)
## Program 3 54.95 18.32 7.045 0.00311 **
## Residuals 16 41.60 2.60
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(fit)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Score ~ Program, data = df)
##
## $Program
## diff lwr upr p adj
## Program2-Program1 -3.0 -5.9176792 -0.08232082 0.0427982
## Program3-Program1 0.4 -2.5176792 3.31767918 0.9788127
## Program4-Program1 -3.2 -6.1176792 -0.28232082 0.0291638
## Program3-Program2 3.4 0.4823208 6.31767918 0.0197459
## Program4-Program2 -0.2 -3.1176792 2.71767918 0.9972140
## Program4-Program3 -3.6 -6.5176792 -0.68232082 0.0133087
p_program <- anova_table[[1]]["Program", "Pr(>F)"]
if (p_program < alpha) {
cat("Decision: Reject H0 at 5% significance level.\n")
cat("Conclusion: At least one training program has a different mean performance.")
} else {
cat("Decision: Fail to reject H0 at 5% significance level.\n")
cat("Conclusion: No significant difference in mean performance among programs.")
}
## Decision: Reject H0 at 5% significance level.
## Conclusion: At least one training program has a different mean performance.