[R] Getting all possible contingency tables

John Kane jrkrideau at inbox.com
Sat Dec 1 13:54:23 CET 2012


Are you basically asking for all possible permutations of the table?  If so see ?permn in the combinat package.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: bogaso.christofer at gmail.com
> Sent: Sat, 01 Dec 2012 18:10:15 +0545
> To: r-help at r-project.org
> Subject: [R] Getting all possible contingency tables
> 
> Hello all,
> 
> Let say I have 2-way contingency table:
> 
> Tab <- matrix(c(8, 10, 12, 6), nr = 2)
> 
> and the Chi-squared test could not reject the independence:
> 
>  > chisq.test(Tab)
> 
>          Pearson's Chi-squared test with Yates' continuity correction
> 
> data:  Tab
> X-squared = 1.0125, df = 1, p-value = 0.3143
> 
> 
> However I want to get all possible contingency tables under this
> independence scenario (one of them would obviously be the given table
> as, we could not reject the independence), and for each such table I
> want to calculate the Ch-sq statistic.
> 
> Can somebody help me how to generate all such tables?
> 
> Thanks and regards,
> 
> ______________________________________________
> 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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!




More information about the R-help mailing list