One method for assessing the bioavailability of a drug is to note its concentration in blood and/or urine samples at certain periods of time after the drug is given. It is useful to compare the concentrations of two types of aspirin (types A and B) in urine specimens taken from the same person 1 hour after he or she has taken the drug. Hence, a specific dosage of either type A or type B aspirin is given at one time and the 1-hour urine concentration is measured.
One week later, after the first aspirin has presumably been cleared from the system, the same dosage of the other aspirin is given to the same person and the 1-hour urine concentration is noted. Because the order of giving the drugs may affect the results, a table of random numbers is used to decide which of the two types of aspirin to give first. This experiment is performed on 10 people; the results are given in the following table.
| Asprin | Measured level in urine sample |
|---|---|
| Asprin A | 15, 26, 13, 28, 17, 20, 7, 36, 12, 18 |
| Asprin B | 13, 20, 10, 21, 17, 22, 5, 30, 7, 11 |
aspA <- c(15, 26, 13, 28, 17, 20, 7, 36, 12, 18)
aspB <- c(13 ,20, 10,21,17,22,5,30,7,11)
State the NULL and Alternate Hypothesis \[H_0 : μ_A = μ_B\]
\[H_1: μ_A ≠ μ_B\]
Test the hypothesis using a paired t-test, report the p-value and state your conclusion (alpha = 0.05)
t.test(aspA,aspB,paired = TRUE)
##
## Paired t-test
##
## data: aspA and aspB
## t = 3.6742, df = 9, p-value = 0.005121
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.383548 5.816452
## sample estimates:
## mean of the differences
## 3.6
Based on the p-value of 0.005121 we would reject the null and conclude that there is a difference between the two mean concentrations
Test this hypothesis using a two-sample t-test (instead of a paired t-test). What would the p-value of your test have been?
Perform the 2 sample t-test with Paired set to FALSE
t.test(aspA,aspB, paired = FALSE)
##
## Welch Two Sample t-test
##
## data: aspA and aspB
## 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
Based on the p-value of 0.3401 we would NOT have rejected the null. This serves as a good example of the difference between pair and two-sample t tests
Researchers want to know if exercise can shorten the time that it takes an infant to learn how to walk alone. They randomly allocated 12 one-week old male infants from white, middle class families to one of two treatment groups. The active exercise group received stimulation of the walking reflexes for four 3-minute sessions each day from the beginning of the second week through the end of the eighth week. Those in the other group received no such stimulation.
The results were are shown in the table below:
| Group | Months to walking |
|---|---|
| Active Exercise | 9.5 ,10, 9.75, 9.75, 9, 13 |
| No Exercise | 11.5, 12, 13.25, 11.5, 13, 9 |
Is there sufficient evidence to conclude that the groups differ in the typical time required to first walking?
aEx <- c(9.5,10,9.75,9.75,9,13)
nEx <- c(11.5,12,13.25,11.5,13,9)
State the Null and Alternate Hypothesis
\[H_0 : μ_1 = μ_2\]
\[H_1: μA ≠ μ_B\]
Why might you want to use a non-parametric method for analyzing this data?
Non-parametric test should be used when the typical assumptions (normality) don’t apply or the data is binary/ordinal
qqnorm(aEx, main = "Active Exercise Group", ylab = "Months to Walk")
qqline(aEx, col="blue")
qqnorm(nEx, main = "No Exercise Group",ylab = "Months to Walk")
qqline(nEx, col="red")
There is an outlier on each plot and a small number of samples, therefore these plots do not look like the follow a straight line so we can assume the data is not normal. This means the non-parametric test is appropriate
Analyze using the Mann-Whitney-U test using R with alpha=0.05
wilcox.test(aEx,nEx)
## Warning in wilcox.test.default(aEx, nEx): cannot compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: aEx and nEx
## W = 9, p-value = 0.1705
## alternative hypothesis: true location shift is not equal to 0
Based on the p-value of 0.1705 we cannot reject the null hypothesis and conclude that the exercise did not change the time required for first walk.
Below you will find a block containing all of the code used to generate this document
aspA <- c(15,26,13,28,17,20,7,36,12,18)
aspB <- c(13,20,10,21,17,22,5,30,7,11)
t.test(aspA,aspB,paired = TRUE)
t.test(aspA,aspB,paired = FALSE)
aEx <- c(9.5,10,9.75,9.75,9,13)
nEx <- c(11.5,12,13.25,11.5,13,9)
qqnorm(aEx, main = "Active Exercise Group", ylab = "Months to Walk")
qqline(aEx, col="blue")
qqnorm(nEx, main = "No Exercise Group",ylab = "Months to Walk")
qqline(nEx, col="red")
wilcox.test(aEx,nEx)