[R] How to compute p-Values

YH Deng yinghai.deng at bri.nrc.ca
Wed Jan 14 16:13:12 CET 2009


I think what you need is just count. For example, if you want to know the p
value of the mean bigger than 0 and you have 5 such cases in your draws then
the p value is 5/1000=0.005, right?

HTH
YHDENG

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Andreas Klein
Sent: January 14, 2009 9:23 AM
To: r help
Subject: Re: [R] How to compute p-Values

Hello.

What I wanted was:

I have a sample of 100 relizations of a random variable and I want a p-Value
for the hypothesis, that the the mean of the sample equals zero (H0) or not
(H1). That is for a two sampled test.
The same question holds for a one sided version, where I want to know if the
mean is bigger than zero (H0) or smaller or equal than zero (H1).

Therfore I draw a bootstrap sample with replacement from the original sample
and compute the mean of that bootstrap sample. I repeat this 1000 times and
obtain 1000 means.

Now: How can I compute the p-Value for an one sided and two sided test like
described above?



Regards,
Andreas


--- gregor rolshausen <gregor.rolshausen at biologie.uni-freiburg.de> schrieb
am Mi, 14.1.2009:

> Von: gregor rolshausen <gregor.rolshausen at biologie.uni-freiburg.de>
> Betreff: Re: [R] How to compute p-Values
> An: "r help" <r-help at r-project.org>
> Datum: Mittwoch, 14. Januar 2009, 11:31
> Andreas Klein wrote:
> > Hello.
> > 
> > 
> > How can I compute the Bootstrap p-Value for a one- and
> two sided test, when I have a bootstrap sample of a
> statistic of 1000 for example?
> > 
> > My hypothesis are for example:
> > 
> > 1. Two-Sided: H0: mean=0 vs. H1: mean!=0
> > 2. One Sided: H0: mean>=0 vs. H1: mean<0
> > 
> >   
> hi,
> do you want to test your original t.test against t.tests of
> bootstrapped samples from you data?
> 
> if so, you can just write a function creating a vector with
> the statistics (t) of the single t.tests (in your case 1000
> t.tests each with a bootstrapped sample of your original
> data -> 1000 simulated t-values).
> you extract them by:
> 
> > tvalue=t.test(a~factor)$statistic
> 
> then just calculate the proportion of t-values from you
> bootstrapped tests that are bigger than your original
> t-value.
> 
> >p=sum(simualted_tvalue>original_tvalue)/1000
> 
> 
> (or did I get the question wrong?)
> 
> cheers,
> gregor
> 
> ______________________________________________
> R-help at 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.




______________________________________________
R-help at 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.




More information about the R-help mailing list