I did a simple little simulation of a binary variable in a two armed trial. I was quite surprised by the number of p-values delivered by the fisher.test function which was >1(!). Of course, under the null hypothesis you expect a fair number of outcomes with the same number of event in both arms but still?
Is there some silly error in my crude code? ########################################################################################## niter<-50000 ra<-rbinom(niter,100,.05) rb<-rbinom(niter,100,.05) pval<-rep(NA,niter) for (i in 1:niter){ apa<-matrix(c(100-ra[i],ra[i],100-rb[i],rb[i]),byrow=T,ncol=2) pval[i]<-fisher.test(apa)$p.value } cbind(ra,rb,pval)[pval < 0.06 & pval > 0.04,] hist(pval,probability=T) summary(pval) table(pval< 0.05)/niter sum(pval>1)/niter ################################################################################################ Patrik Öhagen Biostatistiker Enheten för effekt och säkerhet 4 Box 26, 751 03 Uppsala Besöksadress: Dag Hammarskjöldsväg 42 Telefon: 018 - 17 49 24, växel: 018 - 17 46 00 Fax: 018 - 54 85 66 patrik.oha...@mpa.se www.lakemedelsverket.se ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.