An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100106/6616b251/attachment.pl>
Generating data from Null Distribution
3 messages · Jim Silverton, robin hankin, Greg Snow
Jim the 2x2 case is reasonably straightforward because the support is quite a small set. With the aylmer package you could do this: > a <- matrix(c(1,5,7,8),2,2) > sample(seq_along(allprobs(a)),100,replace=TRUE,prob=allprobs(a)) [1] 3 2 4 1 3 4 4 4 4 3 3 4 4 2 3 4 5 4 3 3 4 4 2 1 4 3 3 3 4 2 3 4 3 4 4 2 3 [38] 3 4 3 4 4 3 4 3 2 3 4 2 3 3 4 2 3 2 3 1 3 5 1 3 2 3 3 4 5 2 5 1 3 3 4 3 5 [75] 4 2 3 4 5 2 3 4 4 3 3 3 4 3 4 6 3 3 4 2 4 4 2 3 2 3 > For bigger tables the matter becomes quite complicated but you can use randomboards() of the aylmer package, which generates random samples using the Metropolis-Hastings algorithm. HTH Robin
Jim Silverton wrote:
Hello everyone, Can someone tell me exactly how to generate data from a null distribution for the fisher exact test? I know I have to use the hypergrometric but exactly what commands do I use? Jim [[alternative HTML version deleted]]
______________________________________________ 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.
Robin K. S. Hankin Uncertainty Analyst University of Cambridge 19 Silver Street Cambridge CB3 9EP 01223-764877
1 day later
Just randomly permute one of your columns (see ?sample) of the raw data (before using the table function to get the table).
Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111 > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Jim Silverton > Sent: Wednesday, January 06, 2010 1:17 AM > To: r-help at r-project.org > Subject: Re: [R] Generating data from Null Distribution > > Hello everyone, > > Can someone tell me exactly how to generate data from a null > distribution > for the fisher exact test? I know I have to use the hypergrometric but > exactly what commands do I use? > > Jim > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.