Question 1

First I enter the data for the 10 people.

A <- c(15, 26, 13, 28, 17, 20, 7, 36, 12, 18)
B <- c(13, 20, 10, 21, 17, 22, 5, 30, 7, 11)

a)

The same person took both types of aspirin, so the data is paired.

H0: the mean difference between A and B is 0 (mu_d = 0)

H1: the mean difference between A and B is not 0 (mu_d != 0)

b)

t.test(A, B, paired = TRUE)
## 
##  Paired t-test
## 
## data:  A and 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 p-value is 0.0051. This is less than 0.05, so we reject H0. There is a difference in the mean concentration of the two aspirins. Aspirin A has a higher concentration, about 3.6 mg% more on average.

c)

If we use a two-sample t-test instead:

t.test(A, B)
## 
##  Welch Two Sample t-test
## 
## data:  A and 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

The p-value would be 0.34. With this test we would not reject H0. This happens because the two-sample test does not use the fact that the measurements come from the same person, so the differences between people make the variation bigger.

Question 2

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)

boxplot(active, no_exercise, names = c("Active", "No Exercise"),
        ylab = "Time (months)")

a)

H0: the mean time to walk is the same for both groups (mu_active = mu_no)

H1: the mean time to walk is less for the active exercise group (mu_active < mu_no)

b)

We might want to use a non-parametric method because the samples are very small (only 6 babies in each group), so it is hard to know if the data is normal. Also, the active group has a value (13.0) that looks like an outlier compared to the others. I checked normality:

shapiro.test(active)
## 
##  Shapiro-Wilk normality test
## 
## data:  active
## W = 0.72061, p-value = 0.01012

The p-value is 0.01, so the active group does not look normal. The Mann-Whitney test does not need the data to be normal.

c)

wilcox.test(active, no_exercise, alternative = "less", exact = FALSE)
## 
##  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 p-value is 0.085. This is greater than 0.05, so we fail to reject H0. There is not enough evidence to say that active exercise makes babies learn to walk faster.