The same 10 people received both types of aspirin. Therefore, the observations are paired.
aspirin_A <- c(15, 26, 13, 28, 17, 20, 7, 36, 12, 18)
aspirin_B <- c(13, 20, 10, 21, 17, 22, 5, 30, 7, 11)
difference <- aspirin_A - aspirin_B
mean(aspirin_A)
## [1] 19.2
mean(aspirin_B)
## [1] 15.6
mean(difference)
## [1] 3.6
sd(difference)
## [1] 3.098387
paired_result <- t.test(
aspirin_A,
aspirin_B,
paired = TRUE,
alternative = "two.sided",
conf.level = 0.95)
paired_result
##
## Paired t-test
##
## data: aspirin_A and aspirin_B
## t = 3.6742, df = 9, p-value = 0.005121
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 1.383548 5.816452
## sample estimates:
## mean difference
## 3.6
The paired t-test gives \(t=3.674\), \(df=9\), and \(P=0.0051\). Since the P-value is less than 0.05, we reject \(H_0\). There is sufficient evidence that the mean urine concentrations of Aspirin A and Aspirin B are different.
two_sample_result <- t.test(
aspirin_A,
aspirin_B,
paired = FALSE,
alternative = "two.sided")
two_sample_result
##
## Welch Two Sample t-test
##
## data: aspirin_A and aspirin_B
## t = 0.9802, df = 17.811, p-value = 0.3401
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.12199 11.32199
## sample estimates:
## mean of x mean of y
## 19.2 15.6
Ignoring the pairing gives \(P\approx0.340\). Since this is greater than 0.05, the two-sample test would fail to reject \(H_0\).
active <- c(9.50, 10.00, 9.75, 9.75, 9.00, 13.00)
no_exercise <- c(11.50, 12.00, 13.25, 11.50, 13.00, 9.00)
mean(active)
## [1] 10.16667
median(active)
## [1] 9.75
mean(no_exercise)
## [1] 11.70833
median(no_exercise)
## [1] 11.75
Each group contains only six infants, so normality is difficult to verify. The Mann–Whitney U test does not require the data to be normally distributed.
mann_whitney_result <- wilcox.test(
active,
no_exercise,
alternative = "less",
paired = FALSE,
exact = FALSE,
correct = TRUE
)
mann_whitney_result
##
## Wilcoxon rank sum test with continuity correction
##
## data: active and no_exercise
## W = 9, p-value = 0.08523
## alternative hypothesis: true location shift is less than 0
The test gives \(U=9\) and \(P\approx0.0852\). Since the P-value is greater than 0.05, we fail to reject \(H_0\). There is insufficient evidence that active exercise shortens the time required for infants to walk independently.