1 Problem 1

1.1 Preperation

First the given data was input into vectors pa and pb

pa <- c(15,26,13,28,17,20,7,36,12,18)  # sample A

pb <- c(13,20,10,21,17,22,5,30,7,11)  # sample B

1.2 Part A

The null hypothesis is that the means are the same. The alternative is that there is a diffrence in the means. Thus this is a two sided T-test. \[H_o:\mu_1=\mu_2 \\ H_a:\mu_1\neq \mu_2 \]

1.3 Part B

A paired T-test is done

t.test(pa,pb,paired= T)
## 
##  Paired t-test
## 
## data:  pa and pb
## 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 from paired T-test is 0.005121 thus the null is rejected!

1.4 Part C

For a two sample T-test,

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

From the two sample T-test the P-value is 0.3401 thus the null hypothesis would not be rejected.

2 Question 2

2.1 Part A

We want to test:

\[H_o:\mu_1=\mu_2 \\ H_a:\mu_1\neq \mu_2 \] where \(\mu_1\) is the mean of infants for active exercise and \(\mu_2\) is the mean of infants for no exercise group.

2.2 Part B

#Creating the data
grp1 <- c(9.5,10,9.75,9.75,9,13)
grp2 <- c(11.5,12,13.25,11.50,13,9)

#Checking for normality
qqnorm(grp1)
qqline(grp1)

qqnorm(grp2)
qqline(grp2)

We will use a non parametric method because the data does not looks normal and we do not have enough data points.

2.3 Part C

#Performing the test
wilcox.test(grp1,grp2)
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  grp1 and grp2
## W = 9, p-value = 0.1705
## alternative hypothesis: true location shift is not equal to 0

We failed to reject the null hypotheses based on the Mann-Whitney test with a p-value of 0.1705.

3 Complete Code

pa <- c(15,26,13,28,17,20,7,36,12,18)  # sample A

pb <- c(13,20,10,21,17,22,5,30,7,11)  # sample B

t.test(pa,pb,paired= T)
t.test(pa,pb)




grp1 <- c(9.5,10,9.75,9.75,9,13)
grp2 <- c(11.5,12,13.25,11.50,13,9)
qqnorm(grp1)
qqline(grp1)
qqnorm(grp2)
qqline(grp2)
wilcox.test(grp1,grp2)