Aspirin_A <- c(15,26,13,28,17,20,7,36,12,18)
Aspirin_B <- c(13,20,10,21,17,22,5,30,7,11)
?t.test
t.test(Aspirin_A,Aspirin_B,paired=TRUE,alternative = c("two.sided"))
## 
##  Paired t-test
## 
## data:  Aspirin_A and Aspirin_B
## 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 to the ques no 1.a.
# Null Hypothesis: H0: u1 = u2 or u1 - u2 = 0
# Alternative Hypothesis: Ha: u1 != u2 or u1 - u2 != 0

# Answer to the ques no 1.b.
# P-value is 0.005121 < 0.05 so we reject H0 which means mean concentration of 
# the two drugs are not the same.

t.test(Aspirin_A,Aspirin_B,paired=FALSE,alternative = c("two.sided"))
## 
##  Welch Two Sample t-test
## 
## data:  Aspirin_A and 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
# Answer to the ques no 1.c.
# P-value is 0.3401 > 0.05 so we fail to reject H0 which means mean concentration of 
# the two drugs are the same.

# Answer to the ques no 2
ActiveExercise <- c(9.50,10.00,9.75,9.75,9.00,13.0)
NoExercise <- c(11.50,12.00,13.25,11.50,13.00,9.00)

# Answer to the ques no 2.a.
# Null Hypothesis: H0: u1 = u2 or u1 - u2 = 0
# Alternative Hypothesis: Ha: u1 != u2 or u1 - u2 != 0

qqnorm(ActiveExercise,main="NPP of Active Exercise",col="blue")
qqline(ActiveExercise)

qqnorm(NoExercise,main="NPP of No Exercise",col="pink")
qqline(NoExercise)

boxplot(ActiveExercise,NoExercise,main ="Exercise Box Plot",names = c("Active Exercise", "No Exercise"),ylab="time in month's")

# Answer to the ques no 2.b.
# 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 to analyze data.

?wilcox.test
wilcox.test(ActiveExercise,NoExercise,alternative ="less")
## Warning in wilcox.test.default(ActiveExercise, NoExercise, alternative =
## "less"): cannot compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  ActiveExercise and NoExercise
## W = 9, p-value = 0.08523
## alternative hypothesis: true location shift is less than 0
# Answer to the ques no 2.c.
# As p value is 0.08523 > 0.05 . Hence we fail to reject  Null Hypotheses and say that mean of 
# Active Exercise and No Exercise are the same.

Source Code

Aspirin_A <- c(15,26,13,28,17,20,7,36,12,18)
Aspirin_B <- c(13,20,10,21,17,22,5,30,7,11)
?t.test
t.test(Aspirin_A,Aspirin_B,paired=TRUE,alternative = c("two.sided"))


t.test(Aspirin_A,Aspirin_B,paired=FALSE,alternative = c("two.sided"))


ActiveExercise <- c(9.50,10.00,9.75,9.75,9.00,13.0)
NoExercise <- c(11.50,12.00,13.25,11.50,13.00,9.00)

qqnorm(ActiveExercise,main="NPP of Active Exercise",col="blue")
qqline(ActiveExercise)

qqnorm(NoExercise,main="NPP of No Exercise",col="pink")
qqline(NoExercise)
boxplot(ActiveExercise,NoExercise,main ="Exercise Box Plot",names = c("Active Exercise", "No Exercise"),ylab="time in month's")

?wilcox.test
wilcox.test(ActiveExercise,NoExercise,alternative ="less")