On 11/10/2005 9:32 AM, Mike Miller wrote: > On Thu, 10 Nov 2005, Ruben Roa wrote: > > >>A statistic is any real-valued or vector-valued function whose >>domain includes the sample space of a random sample. The >>p-value is a real-valued function and its domain includes the >>sample space of a random sample. The p-value has a sampling >>distribution. The code below, found with Google ("sampling distribution >>of the p-value" "R command") shows the sampling >>distribution of the p-value for a t-test of a mean when the null hypothesis >>is true. >>Ruben >> >>n<-18 >>mu<-40 >>pop.var<-100 >>n.draw<-200 >>alpha<-0.05 >>draws<-matrix(rnorm(n.draw * n, mu, sqrt(pop.var)), n) >>get.p.value<-function(x) t.test(x, mu = mu)$p.value >>pvalues<-apply(draws, 2, get.p.value) >>hist(pvalues) >>sum(pvalues <= alpha) >>[1] 6 > > > > The sampling distribution of a p-value when the null hypothesis is true > can be given more simply by this R code: > > runif() > > That holds for any valid test, not just a t test, that produces p-values > distributed continuously on [0,1]. Discrete distributions can't quite do > that without special tweaking.
Nor can most composite null hypotheses, e.g. H0: mu <= 0 versus H1: mu > 0 A t-test may be an appropriate test, but its p-value is not uniformly distributed when mu is -1, even though the null is true. Duncan Murdoch ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html