Test for Normality #QQ-Plot X<-C(145130120140120

Test for Normality #QQ-Plot X<-C(145130120140120

#Test for Normality #Q-Q-Plot x<-c(145,130,120,140,120) qqnorm(x) qqline(x, col = 2,lwd=3) y<-c(159,147,145,137,135) qqnorm(y) qqline(y, col = 2,lwd=3) #Lilliefors Test #install.packages("nortest") library(nortest) x<-c(145,130,120,140,120) y<-c(159,147,145,137,135) lillie.test(x) ## ## Lilliefors (Kolmogorov-Smirnov) normality test ## ## data: x ## D = 0.23267, p-value = 0.4998 lillie.test(y) ## ## Lilliefors (Kolmogorov-Smirnov) normality test ## ## data: y ## D = 0.20057, p-value = 0.7304 #Mann-Whitney-U Test #MWU Test: unpaired data x<-c(5,5,4,5,3) y<-c(22,14,5,17,30) #exact MWU Test, problem with ties wilcox.test(x,y) ## Warning in wilcox.test.default(x, y): cannot compute exact p-value with ## ties ## ## Wilcoxon rank sum test with continuity correction ## ## data: x and y ## W = 1.5, p-value = 0.02363 ## alternative hypothesis: true location shift is not equal to 0 #asymptotic MWU Test with continuity correction wilcox.test(x,y,exact=FALSE, correct=FALSE) ## ## Wilcoxon rank sum test ## ## data: x and y ## W = 1.5, p-value = 0.01775 ## alternative hypothesis: true location shift is not equal to 0 #asymptotic MWU Test without continuity correction wilcox.test(x,y,exact=FALSE, correct=TRUE) ## ## Wilcoxon rank sum test with continuity correction ## ## data: x and y ## W = 1.5, p-value = 0.02363 ## alternative hypothesis: true location shift is not equal to 0 #Calculating the ranks salve<-c(x,y) group<-c(rep("A",length(x)),rep("B",length(y))) data<-data.frame(salve,group) r1<-sum(rank(data$salve)[data$group=="A"]) r1 ## [1] 16.5 r2<-sum(rank(data$salve)[data$group=="B"]) r2 ## [1] 38.5 #Test statistic without correction for ties U1<-length(x)*length(y)+(length(x)*(length(x)+1)/2)-r1 U1 ## [1] 23.5 U2<-length(y)*length(y)+(length(y)*(length(y)+1)/2)-r2 U2 ## [1] 1.5 u<-min(U1,U2) u ## [1] 1.5 #exact non-parametric test Mann Whitney-U test in case of ties #install.packages("coin") library(coin) #exact Mann-Whitney-U Test a<-c(5,5,4,5,3) b<-c(22,14,5,17,30) data<-c(a,b) group<-as.factor(c(rep("A",length(a)),rep("B",length(b)))) wilcox.test(data~group,correct=FALSE) ## Warning in wilcox.test.default(x = c(5, 5, 4, 5, 3), y = c(22, 14, 5, 17, : ## cannot compute exact p-value with ties ## ## Wilcoxon rank sum test ## ## data: data by group ## W = 1.5, p-value = 0.01775 ## alternative hypothesis: true location shift is not equal to 0 wilcox_test(data~group,distribution = "exact") ## ## Exact Wilcoxon-Mann-Whitney Test ## ## data: data by group (A, B) ## Z = -2.3708, p-value = 0.03175 ## alternative hypothesis: true mu is not equal to 0 wilcox_test(data~group,distribution = "asymptotic") ## ## Asymptotic Wilcoxon-Mann-Whitney Test ## ## data: data by group (A, B) ## Z = -2.3708, p-value = 0.01775 ## alternative hypothesis: true mu is not equal to 0 wilcox_test(data~group,distribution = approximate(nresample = 10000)) ## ## Approximative Wilcoxon-Mann-Whitney Test ## ## data: data by group (A, B) ## Z = -2.3708, p-value = 0.0321 ## alternative hypothesis: true mu is not equal to 0 #Wilcoxon Test #Wilcoxon Test: paired data m1<-c(54.5,60.4,85.6,78.2,120.6,121) m2<-c(55.5,69.6,86.7,81.6,116.5,115) wilcox.test(m1,m2,paired=TRUE) ## ## Wilcoxon signed rank test ## ## data: m1 and m2 ## V = 9, p-value = 0.8438 ## alternative hypothesis: true location shift is not equal to 0 #Asymptotic Mann-Whitney-U test for a large sample size #ASA score score<-c(1,2,3,4,5) wa<-c(10,15,16,17,12)#weights for verum group A wb<-c(14,13,14,19,10)#weights for placebo group B a<-rep(score,wa)#weighted values group A b<-rep(score,wb)#weighted values group B table(a) ## a ## 1 2 3 4 5 ## 10 15 16 17 12 table(b) ## b ## 1 2 3 4 5 ## 14 13 14 19 10 wilcox.test(a,b) ## ## Wilcoxon rank sum test with continuity correction ## ## data: a and b ## W = 2560, p-value = 0.6407 ## alternative hypothesis: true location shift is not equal to 0 wilcox.test(a,b,correct=FALSE,exact=FALSE) ## ## Wilcoxon rank sum test ## ## data: a and b ## W = 2560, p-value = 0.6392 ## alternative hypothesis: true location shift is not equal to 0 #or use the exact test data<-c(a,b) group<-as.factor(c(rep("verum",70),rep("placebo",70))) wilcox_test(data~group,distribution = "exact") ## ## Exact Wilcoxon-Mann-Whitney Test ## ## data: data by group (placebo, verum) ## Z = -0.46879, p-value = 0.6457 ## alternative hypothesis: true mu is not equal to 0 #Sample Size Estimation #Package PWR #Plot of Sample Size vs. Power library(pwr) pplott<-pwr.t.test( n = NULL, d= (13)/(sqrt((15^2+18^2)/2)), #Cohen's Effect Size d sig.level = 0.05, power = 0.80, alternative = "two.sided", type="two.sample") plot(pplott) #Binomial Test binom.test(18,21,p=0.60) ## ## Exact binomial test ## ## data: 18 and 21 ## number of successes = 18, number of trials = 21, p-value = 0.01457 ## alternative hypothesis: true probability of success is not equal to 0.6 ## 95 percent confidence interval: ## 0.636576 0.969511 ## sample estimates: ## probability of success ## 0.8571429 pval=0 given=dbinom(18,21,p=0.60) for(i in 0:21) { if(dbinom(i,21,p=0.60) <= given ) pval <- pval + dbinom(i,21,p=0.60) } pval ## [1] 0.01457455 .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us