Question 1 )

Question 1a)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.

Null Hypothesis: Ho:u1=u2 :u1-u2=0 (mean of aspirin a is equal to mean of aspirin b)

Alternate Hypothesis: Ha : u1=!u2 :u1-u2=!0(mean of aspirin a and aspirin b are not equal)

Question 1b)Test the hypothesis using a paired t-test, report the p-value and state your conclusion (alpha = 0.05)

Lets see first if we have a positive correlation in two samples so that we can levearge reducing standard error using paired t test

cor(dat1$aspirinA,dat1$aspirinB)
## [1] 0.9338095

As we can see correlation is high , hence we definetly use paired t test .

library(dplyr)
t.test(dat1$aspirinA,dat1$aspirinB,paired=TRUE)
## 
##  Paired t-test
## 
## data:  dat1$aspirinA and dat1$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

Answer - Here are P value is < 0.05 , Hence accept we can say that we reject Null Hypotheses that means are equal for two given sample

Question 1c) 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?

t.test(dat1$aspirinA,dat1$aspirinB,alternative = "two.sided",paired = FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  dat1$aspirinA and dat1$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

Answer : P value is 0.3401

Question 2

aex <- c(9.50,10.00,9.75,9.75,9.00,13.0)
nex <- c(11.50,12.00,13.25,11.50,13.00,9.00)
matB <- cbind(aex,nex)
dat2 <- as.data.frame(matB)

Question 2)A - State Hypotheses

Answer: Null Hypotheses: Ho : u1=u2 :u1-u2=0 (means of aex and nex are equal)

           **Alternative Hypotheses: Ha : u1<u2 :u1-u2<0 (mean of aex is smaller than nex)**

2b)Why might you want to use a non-parametric method for analyzing this data?

qqnorm(dat2$aex,main = "Active Execise")
qqline(dat2$aex)

qqnorm(dat2$nex,main="No Exercise")
qqline(dat2$nex)

boxplot(dat2$aex,dat2$nex)

Answer : As we can see, we don’t have enough data points to make any claims about normality and constant variances. If we had more data points , then using normal probability plot we could have made some decision about the data’s probability distribution. Hence we might want to use Non Parametric Test

c)Analyze using the Mann-Whitney-U test using R with alpha=0.05

wilcox.test(dat2$aex,dat2$nex,,alternative="less")
## Warning in wilcox.test.default(dat2$aex, dat2$nex, , alternative = "less"):
## cannot compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  dat2$aex and dat2$nex
## W = 9, p-value = 0.08523
## alternative hypothesis: true location shift is less than 0

Answer : As p value is 0.085 > 0.05 . Hence we accept Null Hypotheses and say that mean of Active Exercise and No Exercise are equal