[R] Getting all possible contingency tables
John Kane
jrkrideau at inbox.com
Sat Dec 1 14:57:55 CET 2012
R can usually do almost anything but if the function exists I am not aware of it. Sorry. I did misunderstand what you were doing.
John Kane
Kingston ON Canada
> -----Original Message-----
> From: bogaso.christofer at gmail.com
> Sent: Sat, 01 Dec 2012 19:33:09 +0545
> To: jrkrideau at inbox.com
> Subject: Re: [R] Getting all possible contingency tables
>
> Thanks John for your reply. However still not clear how I should proceed.
>
> My goal is to generate all possible contingency tables. Basically I want
> to see the distribution of Chi-squared Statistic under independence
> (NULL).
>
> So I was thinking if I can generate all possible permutation of integer
> numbers having sum equal to (8 + 10 + 12 + 6) = 36. Is there any R
> function to do that?
>
> Thanks and regards,
>
>
> On 01-12-2012 18:39, John Kane wrote:
>> 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!
>>
>>
>>
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list