1 Problem 1: Aspirin Concentrations

We have been tasked with comparing the concentrations of two different types of aspirin in urine one hour after consumption. Ten people consumed both types of aspirin one week apart from each other, and the concentrations of aspirin were recorded one hour later. The implementation of the recorded data into this report can be seen in the code chunk below.

x<-c("Person", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
y<-c("Aspirin A", 15, 26, 13, 28, 17, 20, 7, 36, 12, 18)
z<-c("Aspirin B", 13, 20, 10, 21, 17, 22, 5, 30, 7, 11)
df1<-data.frame(x, y, z)
colnames(df1)<-df1[1,]
df1<-df1[-1,]
df1$'Person'<-as.factor(df1$Person)
df1$'Aspirin A'<-as.numeric(df1$'Aspirin A')
df1$'Aspirin B'<-as.numeric(df1$'Aspirin B')
rmarkdown::paged_table(df1)

Now, box plots and normal probability plots will be generated for the data to verify normality and whether or not there is constant variance. These figures are generated through the code chunk below.

boxplot(df1$'Aspirin A', df1$'Aspirin B', main = "Aspirin A and B Box Plots", names = c("Aspirin A", "Aspirin B"), ylab = "mg%", col = c("blue", "red"))

qqnorm(df1$'Aspirin A', main = "Normal Probability Plot for Aspirin A", ylab = "mg%", col = "blue")

qqnorm(df1$'Aspirin B', main = "Normal Probability Plot for Aspirin B", ylab = "mg%", col = "red")

The Inner Quartile Range between the two populations differ in size slightly but are comparable enough that a transformation of the data is not required. The whisker lengths are quite a bit different, so we will assume that there is not constant variance. Both normal probability plots seem to have a linear trend, so we can deduce that these data sets have normality.

1.1 1.A Test Hypothesis

The null hypothesis for this data set is that the mean concentrations of the two drugs are the same in urine specimens. This can be expressed through the equation below.

\[H_{o}:\mu_{1}-\mu_{2}=0\]

The alternative hypothesis for this data set is that the mean concentrations of the two drugs are not the same in urine specimens. This can be expressed through the equation below.

\[H_{1}:\mu_{1}-\mu_{2}\neq 0\]

1.2 1.B Paired T-Test

This hypothesis will be tested by utilizing a Paired T-Test on the recorded data set. A level of significance of \(\alpha=0.05\) will be used for this test. The code for the T-Test can be seen in the code chunk below.

t.test(df1$`Aspirin A`, df1$`Aspirin B`, alternative = c("two.sided"), mu = 0, paired = TRUE, var.equal = FALSE, conf.level = 0.95)
## 
##  Paired t-test
## 
## data:  df1$`Aspirin A` and df1$`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 p-value for this T-Test is 0.005121, which is less than the level of significance of 0.05. Therefore, the null hypothesis is rejected and we conclude that the mean concentrations of the two drugs are not equal.

1.3 1.C Two-Sample T-Test

Now, we will perform a Two-Sample T-Test with the data unpaired to see how this affects the results. The code for the T-Test can be seen in the code chunk below.

t.test(df1$`Aspirin A`, df1$`Aspirin B`, alternative = c("two.sided"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95)
## 
##  Welch Two Sample t-test
## 
## data:  df1$`Aspirin A` and df1$`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

The p-value for this T-Test is 0.3401, which is greater than the level of significance of 0.05. Therefore, the null hypothesis is not rejected and we are unable to conclude that the mean concentrations of the two drugs are not equal.

2 Problem 2: Infant Walk Times

We have been tasked with comparing the time it takes for infants to begin walking independently between two different groups. The active exercise group of infants are stimulated with walking reflexes for four 3-minute sessions each day for seven straight weeks. The no exercise group of infants do not receive any exercise stimulation. An analysis will be performed to determine if there is evidence that the mean walk time is less for infants who receive active exercise when compared to infants who do not receive active exercise. Six infants were put into each group, and the implementation of the recorded data into this report can be seen in the code chunk below.

a<-c("Active Exercise", 9.5, 10, 9.75, 9.75, 9, 13)
b<-c("No Exercise", 11.5, 12, 13.25, 11.5, 13, 9)
df2<-data.frame(a, b)
colnames(df2)<-df2[1,]
df2<-df2[-1,]
df2$'Active Exercise'<-as.numeric(df2$'Active Exercise')
df2$'No Exercise'<-as.numeric(df2$'No Exercise')
rmarkdown::paged_table(df2)

2.1 2.A Test Hypothesis

The null hypothesis for this data set is that the mean walk times of the two groups of infants are the same and that the exercise stimulus has no affect. This can be expressed through the equation below.

\[H_{o}:\mu_{1}-\mu_{2}=0\]

The alternative hypothesis for this data set is that the mean walk times of the two groups of infants are not the same and that the exercise stimulus accelerates an infant’s ability to walk. This can be expressed through the equation below.

\[H_{1}:\mu_{1}-\mu_{2}<0\]

2.2 2.B Non-Parametric Method

The Non-Parametric Method is appropriate in this case because of the size of the data set. With a data set of only six observations in each population, it makes it very difficult to determine normality of the populations. Since normality cannot be assumed, it creates a good opportunity to use the Non-Parametric Method.

2.3 2.C Mann-Whitney Test

This hypothesis will be tested by performing a Mann-Whitney Test on the recorded data set. A level of significance of \(\alpha=0.05\) will be used for this test. The data will be unpaired since there is no relationship between the two populations. Additionally, the test will be one-sided since we are checking if the exercise stimulus reduces infant walk times. The code for the T-Test can be seen in the code chunk below.

wilcox.test(df2$'Active Exercise', df2$'No Exercise', alternative = c("less"), mu = 0, paired = FALSE, conf.level = 0.95)
## 
##  Wilcoxon rank sum exact test
## 
## data:  df2$"Active Exercise" and df2$"No Exercise"
## W = 9, p-value = 0.09524
## alternative hypothesis: true location shift is less than 0

The p-value for this Mann-Whitney Test is 0.09524, which is greater than the level of significance of 0.05. Therefore, the null hypothesis is not rejected and we cannot conclude that the mean infant walk time of the exercise stimulus group is less than the no exercise group.

3 Complete R Code

# Problem 1: Aspirin Concentrations
x<-c("Person", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
y<-c("Aspirin A", 15, 26, 13, 28, 17, 20, 7, 36, 12, 18)
z<-c("Aspirin B", 13, 20, 10, 21, 17, 22, 5, 30, 7, 11)
df1<-data.frame(x, y, z)
colnames(df1)<-df1[1,]
df1<-df1[-1,]
df1$'Person'<-as.factor(df1$Person)
df1$'Aspirin A'<-as.numeric(df1$'Aspirin A')
df1$'Aspirin B'<-as.numeric(df1$'Aspirin B')
rmarkdown::paged_table(df1)

boxplot(df1$'Aspirin A', df1$'Aspirin B', main = "Aspirin A and B Box Plots", names = c("Aspirin A", "Aspirin B"), ylab = "mg%", col = c("blue", "red"))
qqnorm(df1$'Aspirin A', main = "Normal Probability Plot for Aspirin A", ylab = "mg%", col = "blue")
qqnorm(df1$'Aspirin B', main = "Normal Probability Plot for Aspirin B", ylab = "mg%", col = "red")

## 1.A Test Hypothesis
$$H_{o}:\mu_{1}-\mu_{2}=0$$
$$H_{1}:\mu_{1}-\mu_{2}\neq 0$$

## 1.B Paired T-Test
t.test(df1$`Aspirin A`, df1$`Aspirin B`, alternative = c("two.sided"), mu = 0, paired = TRUE, var.equal = TRUE, conf.level = 0.95)

## 1.C Two-Sample T-Test
t.test(df1$`Aspirin A`, df1$`Aspirin B`, alternative = c("two.sided"), mu = 0, paired = FALSE, var.equal = TRUE, conf.level = 0.95)

# Problem 2: Infant Walk Times
a<-c("Active Exercise", 9.5, 10, 9.75, 9.75, 9, 13)
b<-c("No Exercise", 11.5, 12, 13.25, 11.5, 13, 9)
df2<-data.frame(a, b)
colnames(df2)<-df2[1,]
df2<-df2[-1,]
df2$'Active Exercise'<-as.numeric(df2$'Active Exercise')
df2$'No Exercise'<-as.numeric(df2$'No Exercise')
rmarkdown::paged_table(df2)

## 2.A Test Hypothesis
$$H_{o}:\mu_{1}-\mu_{2}=0$$
$$H_{1}:\mu_{1}-\mu_{2}<0$$

## 2.C Mann-Whitney Test
wilcox.test(df2$'Active Exercise', df2$'No Exercise', alternative = c("less"), mu = 0, paired = FALSE, conf.level = 0.95)