Tahira Jamil
2014-Jun-24 14:41 UTC
[R] Sample all possible contingency tables both margin fixed
Hi, I am interested in generating all possible contingency table (2 by 2) with fixed row margins and column margins. Can anyone help me. Best regards, Tahira [[alternative HTML version deleted]]
Gabor Grothendieck
2014-Jun-24 17:07 UTC
[R] Sample all possible contingency tables both margin fixed
On Tue, Jun 24, 2014 at 10:41 AM, Tahira Jamil <tahjamil at gmail.com> wrote:> Hi, > > I am interested in generating all possible contingency table (2 by 2) with fixed row margins and column margins. Can anyone help me. >If the reason you want this is to sample them then r2dtable can do that directly.
peter dalgaard
2014-Jun-24 17:58 UTC
[R] Sample all possible contingency tables both margin fixed
On 24 Jun 2014, at 16:41 , Tahira Jamil <tahjamil at gmail.com> wrote:> Hi, > > I am interested in generating all possible contingency table (2 by 2) with fixed row margins and column margins. Can anyone help me. >It's pretty easy, just find one compatible solution and add or subtract 1 -1 -1 1 until one of the numbers would go negative. Or put differently, if you know one entry, you know the other three, so it is just a matter of working out the range of (say) possible top-left entries. With more than 2x2 tables it is much harder, but fisher.test() does it internally. -pd> Best regards, > Tahira > [[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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com