A one-way ANOVA compares mean reported scores for the high-, moderate-, and low-stress groups. The significance level is 0.05. The null hypothesis is that all three population means are equal; the alternative is that at least one differs. Although the prompt also mentions reaction time, the reported scale is 1–10, so these observations are analyzed as reported scores.
stress <- data.frame(
group = factor(rep(c("High", "Moderate", "Low"), each = 6),
levels = c("High", "Moderate", "Low")),
score = c(10, 9, 8, 9, 10, 8,
8, 10, 6, 7, 8, 8,
4, 6, 6, 4, 2, 2)
)
aggregate(score ~ group, stress,
function(x) c(n = length(x), mean = mean(x), sd = sd(x)))
## group score.n score.mean score.sd
## 1 High 6.000000 9.000000 0.894427
## 2 Moderate 6.000000 7.833333 1.329160
## 3 Low 6.000000 4.000000 1.788854
stress_model <- aov(score ~ group, data = stress)
summary(stress_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## group 2 82.1 41.1 21.4 4.1e-05 ***
## Residuals 15 28.8 1.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
| Source | Df | Sum Sq | Mean Sq | F value | Pr(>F) |
|---|---|---|---|---|---|
| Stress group | 2 | 82.1111 | 41.0556 | 21.3584 | 0.0000408244 |
| Residuals | 15 | 28.8333 | 1.9222 |
Df means degrees of freedom. Sum Sq
measures variation attributable to each source. Mean Sq is
Sum Sq divided by Df. The F statistic is the between-group mean square
divided by the residual mean square. Pr(>F) is the
p-value for the test.
The group means are 9.00 (high stress), 7.83 (moderate stress), and 4.00 (low stress). The test gives F(2, 15) = 21.3584, p = 0.0000408244. Because p < 0.05, the null hypothesis is rejected. There is evidence that mean reported scores differ among the groups. The omnibus ANOVA alone does not identify which pairs differ.
These data do not establish that the drug reduces stress. Everyone received the drug, and no untreated/placebo group or before-and-after measurements are provided. The analysis compares groups under the reported conditions, rather than estimating a drug effect.
The zelazo data record age at walking in months in four
groups: active training, passive training, no training, and an
eighth-week control group. A one-way ANOVA is
appropriate because the dataset contains one grouping factor with four
levels and one numeric outcome. It does not provide a crossed two-factor
design for a two-way ANOVA.
The null hypothesis is that all four population mean walking ages are equal. The alternative is that at least one differs. The significance level is 0.05.
# Install ISwR in the Console first if necessary:
# install.packages("ISwR")
data("zelazo", package = "ISwR")
# Convert the list of vectors into a data frame suitable for lm().
walking <- stack(zelazo)
names(walking) <- c("age", "group")
walking
## age group
## 1 9.00 active
## 2 9.50 active
## 3 9.75 active
## 4 10.00 active
## 5 13.00 active
## 6 9.50 active
## 7 11.00 passive
## 8 10.00 passive
## 9 10.00 passive
## 10 11.75 passive
## 11 10.50 passive
## 12 15.00 passive
## 13 11.50 none
## 14 12.00 none
## 15 9.00 none
## 16 11.50 none
## 17 13.25 none
## 18 13.00 none
## 19 13.25 ctr.8w
## 20 11.50 ctr.8w
## 21 12.00 ctr.8w
## 22 13.50 ctr.8w
## 23 11.50 ctr.8w
aggregate(age ~ group, walking,
function(x) c(n = length(x), mean = mean(x), sd = sd(x)))
## group age.n age.mean age.sd
## 1 active 6.000000 10.125000 1.446980
## 2 passive 6.000000 11.375000 1.895719
## 3 none 6.000000 11.708333 1.520005
## 4 ctr.8w 5.000000 12.350000 0.961769
walking_model <- lm(age ~ group, data = walking)
anova(walking_model)
## Analysis of Variance Table
##
## Response: age
## Df Sum Sq Mean Sq F value Pr(>F)
## group 3 14.78 4.926 2.142 0.129
## Residuals 19 43.69 2.299
| Source | Df | Sum Sq | Mean Sq | F value | Pr(>F) |
|---|---|---|---|---|---|
| Group | 3 | 14.7778 | 4.9259 | 2.1422 | 0.128546 |
| Residuals | 19 | 43.6896 | 2.2995 |
| Group | Sample size | Mean walking age (months) |
|---|---|---|
| Active | 6 | 10.1250 |
| Passive | 6 | 11.3750 |
| None | 6 | 11.7083 |
| Eighth-week control | 5 | 12.3500 |
The test gives F(3, 19) = 2.1422, p = 0.128546. Because p > 0.05, the null hypothesis is not rejected. There is insufficient evidence of a difference in mean walking age across the four groups. Although the active group has the lowest sample mean, this pattern alone does not establish a population difference.
The following exploratory comparisons use two-sided, equal-variance two-sample t-tests. Each test estimates variance from its included groups. The combined comparison groups active and passive training together and compares them with the two groups receiving no training. Combining groups assumes the broader training-versus-no-training comparison is scientifically meaningful.
active_passive <- t.test(zelazo$active, zelazo$passive, var.equal = TRUE)
none_control <- t.test(zelazo$none, zelazo$ctr.8w, var.equal = TRUE)
training_control <- t.test(
c(zelazo$active, zelazo$passive),
c(zelazo$none, zelazo$ctr.8w),
var.equal = TRUE
)
tests <- list(active_passive, none_control, training_control)
comparisons <- data.frame(
comparison = c("Active vs passive", "None vs eighth-week control",
"Combined training vs combined no training"),
t = sapply(tests, function(x) unname(x$statistic)),
df = sapply(tests, function(x) unname(x$parameter)),
p = sapply(tests, function(x) x$p.value)
)
comparisons$p_Holm <- p.adjust(comparisons$p, method = "holm")
comparisons
## comparison t df p p_Holm
## 1 Active vs passive -1.283881 10 0.2281327 0.456265
## 2 None vs eighth-week control -0.814011 9 0.4366452 0.456265
## 3 Combined training vs combined no training -1.950474 21 0.0645929 0.193779
Active versus passive training gives t(10) = -1.2839, p = 0.2281. No training versus eighth-week controls gives t(9) = -0.8140, p = 0.4366. Combined training versus combined no training gives t(21) = -1.9505, p = 0.0646, with respective means of 10.75 and 12.00 months. None is significant at 0.05, even before adjustment. Holm adjustment for the three exploratory comparisons also leaves all comparisons nonsignificant. Failure to reject does not prove that the groups are equivalent.
Classical ANOVA assumes independent observations, approximately normal within-group errors, and similar population variances. The pooled t-tests also assume similar variances. Independence depends on the study design. The samples are small, and the first outcome is a bounded rating scale, so these assumptions deserve caution. The following plots allow inspection of residual spread and normality; they cannot establish independence.
par(mfrow = c(2, 2))
plot(stress_model, which = 1, main = "Stress: residuals")
plot(stress_model, which = 2, main = "Stress: normality")
plot(walking_model, which = 1, main = "Walking: residuals")
plot(walking_model, which = 2, main = "Walking: normality")
par(mfrow = c(1, 1))
Dalgaard, P. (2008). Introductory statistics with R (2nd ed.). Springer. Chapter 7, Exercise 7.1.
ISwR package documentation, Age at walking: https://cran.r-universe.dev/ISwR/doc/manual.html#zelazo