# B' εργαστηριακή άσκηση στους ελέγχους υποθέσεων. # Άσκηση 1 no.tv<-c(6, 11, 9, 8, 9, 8, 7, 10, 11, 9) tv<- c(6, 10, 9, 7, 8, 9, 7, 9, 9, 8) dif<-no.tv-tv mean(no.tv); mean(tv) ; mean(dif) hist(dif) qqnorm(dif); qqline(dif) t.test(dif, conf.level=0.99, alternative="greater") wilcox.test(dif, conf.level=0.99, alternative="greater") # ties.. library(exactRankTests) wilcox.exact(dif, conf.level=0.99, alternative="greater") # Άσκηση 2 therapy<-c(rep("rad",18), rep("chem",20), rep("both",12)) improved<-c(rep("yes",12),rep("no",6),rep("yes",12),rep("no",8),rep("yes",5),rep("no",7)) t<-table(improved,therapy) prop.table(t) prop.table(t,1) prop.table(t,2) barplot(prop.table(t), names.arg=c( "both", "chemotherapy", "radiotherapy"), legend.text=c("not improved","improved"), col=c(1,3), ylim=c(0,0.6)) # alternative barplot. barplot(prop.table(t), names.arg=c("both", "chemotherapy", "radiotherapy"), legend.text=c("not improved","improved"), beside=T,col=1:2, ylim=c(0,0.4)) a<-chisq.test(t) a a$p.value a$expected a$observed 21*12/50 # =5.04 # Άσκηση 3 data<-rbind(c(17,8), c(22,4)) prop.table(data) pie(prop.table(data), labels=c("A and B", "B not A", "A not B", "none"),col=1:4) mcnemar.test(data)