QUESTION 2.32
#importing the given data
clp1<-c(0.265,0.265,0.266,0.267,0.267,0.265,0.267,0.267,0.265,0.268,0.268,0.265)
clp2<-c(0.264,0.265,0.264,0.266,0.267,0.268,0.264,0.265,0.265,0.267,0.268,0.269)
#As the given data is dependent, non parametric (wilcox test) test is used
#using Wilcox test
wilcox.test(clp1,clp2,conf.int = TRUE,conf.level = 0.95)
## Warning in wilcox.test.default(clp1, clp2, conf.int = TRUE, conf.level = 0.95):
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(clp1, clp2, conf.int = TRUE, conf.level = 0.95):
## cannot compute exact confidence intervals with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: clp1 and clp2
## W = 81, p-value = 0.6131
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## -0.001025110 0.001965484
## sample estimates:
## difference in location
## 1.444043e-05
#answer 2.32 a
#As P value 0.6131 is greater than alpha 0.05, so here we fail to reject null hypotheses and there is no significant difference to conclude that two samples were selected
#answer 2.32 b
#By the wilcox test P value is 0.6131
#answer 2.32 c
#At the confidence interval, lower limit is -0.001025110 and upper limit is 0.001965484
QUESTION 2.34
#NULL HYPOTHESES H0:MU1 EQ MU2
#ALTERNATE HYPOTHESES H1:MU1 NE MU2
#importing the given data
M1<-c(1.186,1.151,1.322,1.339,1.200,1.402,1.365,1.537,1.559)
M2<-c(1.061,0.992,1.063,1.062,1.065,1.178,1.037,1.086,1.052)
d<-cbind(M1,M2)
d<-as.data.frame(d)
cor(d$'M1',d$'M2')
## [1] 0.3821669
#MANN WHITNEY TEST
wilcox.test(M1,M2,conf.int = TRUE,conf.level = 0.95)
##
## Wilcoxon rank sum exact test
##
## data: M1 and M2
## W = 80, p-value = 8.227e-05
## alternative hypothesis: true location shift is not equal to 0
## 95 percent confidence interval:
## 0.135 0.381
## sample estimates:
## difference in location
## 0.277
#Answer 2.34 a
#As P Value 8.227e, we reject the NULL HYPOTHESES H0,so we conclude that there is an enough eveidence to support there is difference in mean
#Answer 2.34 b
#P value for the test is 8.227e
#Answer 2.34 c
#for 95 percent confidence interval,lower limit is 0.135 and upper limit is 0.381
#Answer 2.34 d
#Normality check
qqnorm(M1,ylab="ratio of method 1",main="Method1")

qqnorm(M2,ylab="ratio of method 2",main="method2")

#after the analysis of both methods m1 and m2 normal plots, the distribution is not normal
#ratio difference
diff<-c(M1,M2)
qqnorm(diff,ylab="ratio",main="differences of two methods")

#the difference of the plot
#Answer 2.34 e
#two sample t test
t.test(M1,M2,paired = TRUE)
##
## Paired t-test
##
## data: M1 and M2
## t = 6.0819, df = 8, p-value = 0.0002953
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 0.1700423 0.3777355
## sample estimates:
## mean difference
## 0.2738889
QUESTION 2.29 e,f
#importing the given data
t1<-c(11.176,7.089,8.097,11.739,11.291,10.759,6.467,8.315)
t2<-c(5.263,6.748,7.461,7.015,8.133,7.418,3.722,8.963)
#normality check for the thickness
# question e
qqnorm(t1,ylab = "thickness at 95",main ="q-q plot of t1")
qqline(t1)

qqnorm(t2,ylab = "thickness at 100",main = "q-q plot of t2")
qqline(t2)

#question f
library(pwr)
?pwr.t.test
## starting httpd help server ... done
pwr.t.test(n=8,d=2.5,sig.level=0.05,power=NULL,type="two.sample")
##
## Two-sample t test power calculation
##
## n = 8
## d = 2.5
## sig.level = 0.05
## power = 0.9962561
## alternative = two.sided
##
## NOTE: n is number in *each* group
#therefore POWER is 0.9962561 by power calculation
QUESTION 2.27
#NULL HYPOTHESIS H0:MU1=MU2
#ALTERNATE HYPOTHESIS HA:MU1 NE MU2
#importing the given data
p1<-c(2.7,4.6,2.6,3.0,3.2,3.8)
p2<-c(4.6,3.4,2.9,3.5,4.1,5.1)
#finding the normal distribution for continuous data
qqnorm(p1)

qqnorm(p2)

#concatenating and finding the normality of two vectors
qqnorm(c(p1,p2))

#using non parametric test or wilcox test
wilcox.test(p1,p2)
## Warning in wilcox.test.default(p1, p2): cannot compute exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: p1 and p2
## W = 9.5, p-value = 0.1994
## alternative hypothesis: true location shift is not equal to 0
#from the wilcox test the P-value is 0.1994
#ANSWER TO QUESTION a
#From the wilcox test P Value is 0.1994 and the ALPHA = 0.05, P Value is greater than ALPHA which means that we fail to reject the hypothesis H0