[R] Sample all possible contingency tables both margin fixed
pdalgd at gmail.com
Tue Jun 24 19:58:59 CEST 2014
On 24 Jun 2014, at 16:41 , Tahira Jamil <tahjamil at gmail.com> wrote:
> 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
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.
> Best regards,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help