Skip to content
Prev 177436 / 398506 Next

Generate bivariate binomial data

On Fri, 17 Apr 2009, ONKELINX, Thierry wrote:

            
The commonly used sampling models for such count data (see Bishop, 
Fienberg, and Holland, Discrete Multivariate Analysis, 1975.) involve four 
parameters. There are various parameterizations.

In your case, the total sample size (N), the proportion of 
undamaged trees at the first (pr.undam.1), and the proportions at the 
second time conditional on the first (p.undam.2.undam.1, p.undam.2.dam.1) 
seems like reasonable way to parameterize the problem to do your 
simulation.

If you have the marginal counts and the correlation, you can transform 
them to the above parameterization by hacking through the algebra to find 
the expected 2 by 2 table of counts as a function of the latter 
parameters.

Then

y <- rbinom( N, 1, pr.undam.1 )
x <- rbinom( N, 1, ifelse(y==1, pr.undam.2.undam.1, pr.undam.2.dam.1 )

table(x,y)

should get you started

HTH,

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901