Importing and sorting data:
aspirinA <- c(15,
26,
13,
28,
17,
20,
7,
36,
12,
18)
aspirinB <- c(13,
20,
10,
21,
17,
22,
5,
30,
7,
11)
aspirin <-cbind(aspirinA, aspirinB)
View(aspirin)
str(aspirin)
## num [1:10, 1:2] 15 26 13 28 17 20 7 36 12 18 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:2] "aspirinA" "aspirinB"
aspirin <- as.data.frame(aspirin)
The Mean concentration of urine samples of A(u1) and Urine samples of B (u2) is equal to zero.
Null Hypothesis, Ho: u1=u2 or u1-u2 = 0
The Mean concentration of urine samples of A(u1) and Urine samples of B (u2) is not equal to zero.
Alternative Hypothesis: Ho: u1≠u2 or u1 - u2 ≠ 0
t.test(aspirin$aspirinA, aspirin$aspirinB, alternative = "two.sided", paired = TRUE )
##
## Paired t-test
##
## data: aspirin$aspirinA and aspirin$aspirinB
## 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
From the Answer the P value is smaller than the level of significance so we have evidence to reject null hypothesis. so we conclude that the mean concentrations of the two drugs are not the same.
t.test(aspirin$aspirinA, aspirin$aspirinB, alternative = "two.sided", paired = FALSE )
##
## Welch Two Sample t-test
##
## data: aspirin$aspirinA and aspirin$aspirinB
## 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
P value is greater than the level of significance so we fail to reject the null hypothesis.
Since we used the two sample t test our degreee of freedom has changed. so our T distribution also changed so we are getting a different p value for the same data. So we are drawing the wrong conclusion if we are using the wrong test method.
Importing and sorting the data:
active <- c(9.50,
10.00,
9.75,
9.75,
9.00,
13.0)
exercise <- c(11.50,
12.00,
13.25,
11.50,
13.00,
9.00)
walk <- cbind(active, exercise)
walk <- as.data.frame(walk)
View(walk)
The Mean walking time of active exercise (u1) and No exercise (u2) is equal to zero.
Null Hypothesis, Ho: u1=u2 or u1-u2 = 0
The Mean walking time of active exercise (u1) and No exercise (u2) is not equal to zero.
Alternative Hypothesis: Ho: u1 - u2 < 0
Since we don’t have a large sample data, we cannot check the normality and the skewness of the data. We see that we have only 6 data points per groups, which is not enough to get information on the normality and variances.
wilcox.test(walk$active, walk$exercise, alternative = "less")
## Warning in wilcox.test.default(walk$active, walk$exercise, alternative =
## "less"): cannot compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: walk$active and walk$exercise
## W = 9, p-value = 0.08523
## alternative hypothesis: true location shift is less than 0
We see that the p-value of the Mann-Whitney U test is greater than our level of significance alpha = 0.05). Hence we fail to reject the null hypothesis which states that the mean walking time of the active and no exercise groups are the same. Thus, we conclude that the active exercise program does not shorten the walking time in an infant.