[R] Simulating n 2x2 tables with the same odds ratio
savicky at cs.cas.cz
Fri Mar 9 16:01:17 CET 2012
On Fri, Mar 09, 2012 at 05:37:42AM -0800, hubinho wrote:
> I'm looking for a method to simulate n different 2x2 tables having all the
> same odds ratio.
> For example.
> I need
> 100 tables with odds ratio 1
> 100 tables with odds ratio 2
> 100 tables with odds ratio 3
> and so on.
> All tables should have the same marginal frequencies.
Marginal frequencies together with the odds ratio determine
the matrix uniquely. So, some of the requirements should
If we start with a matrix
then all matrices with the same marginal frequencies have
(a + t, b - t)
(c - t, d + t)
The odds ratio is
which is a strictly increasing function of t and so the equation
(a+t)(d+t)/(c-t)/(b-y) = odds
for a given odds has a unique solution t.
More information about the R-help