[R] null distribution of binom.test p values

Chris Wallace chris.wallace at cimr.cam.ac.uk
Thu Jan 26 13:43:47 CET 2012


Dear R-help,

I must be missing something very obvious, but I am confused as to why 
the null distribution for p values generated by binom.test() appears to 
be non-uniform.  The histogram generated below has a trend towards 
values closer to 1 than 0.  I expected it to be flat.

hist(sapply(1:1000, function(i,n=100) 
binom.test(sum(rnorm(n)>0),n,p=0.5,alternative="two")$p.value))

This trend is more pronounced for small n, and the distribution appears 
uniform for larger n, say n=1000.  I had expected the distribution to be 
discrete for small n, but not skewed.  Can anyone explain why?

Many thanks,

Chris.



More information about the R-help mailing list