[R] How to find statistics like that.

Ruben Roa RRoa at fisheries.gov.fk
Thu Nov 10 14:41:30 CET 2005


> -----Original Message-----
> From:	Mike Miller [SMTP:mbmiller at taxa.epi.umn.edu]
> Sent:	Thursday, November 10, 2005 12:32 PM
> To:	Ruben Roa
> Cc:	ramasamy at cancer.org.uk; Duncan Murdoch; r-help at stat.math.ethz.ch
> Subject:	Re: [R] How to find statistics like that.
> 
> 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.
> 
> Mike
> 
------------
Theorem 2.1.4 in Casella and Berger (1990, p. 52).
Ruben




More information about the R-help mailing list