# Setup and Preallocation
# setup Libraries
library(dplyr)
library(knitr)
library(lawstat)
library(BSDA)
# DataFrame for Problem 1
asprinUrine <- data.frame(
persons = c(1:10),
AsprinA = c(12,26,13,28,17,20,7,36,12,18),
AsprinB = c(13,20,10,21,17,22,5,30,7,11))
# DataFrame for Problem 2
babyWalkers <- data.frame(
activeExercise = c(9.5,10,9.75,9.75,9,13),
noExercise = c(11.5,12,13.25,11.5,13,9))
These are our following two hypothesis,
cor(asprinUrine$AsprinA,asprinUrine$AsprinB)
## [1] 0.9240307
t.test(asprinUrine$AsprinA,asprinUrine$AsprinB,paired = TRUE)
##
## Paired t-test
##
## data: asprinUrine$AsprinA and asprinUrine$AsprinB
## t = 3.0684, df = 9, p-value = 0.01339
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.8670853 5.7329147
## sample estimates:
## mean of the differences
## 3.3
t.test(asprinUrine$AsprinA,asprinUrine$AsprinB,var.equal = TRUE)
##
## Two Sample t-test
##
## data: asprinUrine$AsprinA and asprinUrine$AsprinB
## t = 0.88644, df = 18, p-value = 0.3871
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.521214 11.121214
## sample estimates:
## mean of x mean of y
## 18.9 15.6
These are our folloing two hypothesis,
These are our folloing two hypothesis,
qqnorm(c(babyWalkers$activeExercise,babyWalkers$noExercise))
wilcox.test(babyWalkers$activeExercise,babyWalkers$noExercise)
##
## Wilcoxon rank sum test with continuity correction
##
## data: babyWalkers$activeExercise and babyWalkers$noExercise
## W = 9, p-value = 0.1705
## alternative hypothesis: true location shift is not equal to 0
# setup Libraries
library(dplyr)
library(knitr)
library(lawstat)
library(BSDA)
# 1
# a) Suppose we want to test the hypothesis that the mean concentrations of the two drugs are the same in urine specimens. State the appropriate hypothesis.
# b) Test the hypothesis using a paired t-test, report the p-value and state your conclusion (alpha = 0.05)
# c) Suppose that you tested this hypothesis using a two-sample t-test (instead of a paired t-test). What would the p-value of your test have been?
asprinUrine <- data.frame(
persons = c(1:10),
AsprinA = c(12,26,13,28,17,20,7,36,12,18),
AsprinB = c(13,20,10,21,17,22,5,30,7,11))
cor(asprinUrine$AsprinA,asprinUrine$AsprinB)
# a
# write stuff here
# b
t.test(asprinUrine$AsprinA,asprinUrine$AsprinB,paired = TRUE)
# u1 - u2 = 0
# p = 0.01339 > 0.005
# reject null
# c
t.test(asprinUrine$AsprinA,asprinUrine$AsprinB,var.equal = TRUE)
# u1 - u2 = 0
# p = 0.3871 > 0.005
# reject null again.
# make sure we do var.equal = TRUE
# 2
# a) State the null and alternative hypothesis
# b) Why might you want to use a non-parametric method for analyzing this data?
# c) Analyze using the Mann-Whitney-U test using R with alpha=0.05
babyWalkers <- data.frame(
activeExercise = c(9.5,10,9.75,9.75,9,13),
noExercise = c(11.5,12,13.25,11.5,13,9))
qqnorm(babyWalkers$activeExercise)
qqnorm(babyWalkers$noExercise)
qqnorm(c(babyWalkers$activeExercise,babyWalkers$noExercise))
# c
wilcox.test(babyWalkers$activeExercise,babyWalkers$noExercise)
# u1 - u2 = 0
# p = 0.1705 > 0.005
# reject null
kable(asprinUrine,caption = "Asprin Data")
| persons | AsprinA | AsprinB |
|---|---|---|
| 1 | 12 | 13 |
| 2 | 26 | 20 |
| 3 | 13 | 10 |
| 4 | 28 | 21 |
| 5 | 17 | 17 |
| 6 | 20 | 22 |
| 7 | 7 | 5 |
| 8 | 36 | 30 |
| 9 | 12 | 7 |
| 10 | 18 | 11 |
kable(babyWalkers,caption = "Baby Walking Data")
| activeExercise | noExercise |
|---|---|
| 9.50 | 11.50 |
| 10.00 | 12.00 |
| 9.75 | 13.25 |
| 9.75 | 11.50 |
| 9.00 | 13.00 |
| 13.00 | 9.00 |