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 I hope you can help me Thanks in advance Regards, Andreas
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
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.
I read the problem a bit differently than Andreas. I thought you were trying to create a *substitute* for the parametric t-test. A p-value is not a statement about a group of tests. It is a statement about one sample of data in comparison with the theoretical (in the case of the parametric test), or on your case, with the bootstrap distribution. You want to construct a CDF of your distribution of means/s.d. values and package it up in a form that would allow you to return the *proportion* of values (the "p-value") above one particular new sample value. ?ecdf #will give you information on how to turn 1000 realizations into a function, it's really pretty simple. If your sample of potentially (but not necessarily) t-like statistics is tt then ttCDF <- ecdf(tt) will return nothing, but result in ttCDF becoming a function. Then with a sample value mean_a to test, you get useful results with: ttCDF(mean_a) Turning this into a "test" requires a bit more packaging but it think the road is clear ahead. -- David Winsemius On Jan 14, 2009, at 4:52 AM, 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 > > > > I hope you can help me > > > Thanks in advance > > > Regards, > Andreas > > > > > ______________________________________________ > 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.
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.
I think we are at the stage where it is your responsibility to provide some code to set up the problem. -- David Winsemius On Jan 14, 2009, at 9:23 AM, Andreas Klein wrote:> 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.