Skip to content
Prev 177884 / 398506 Next

Generate bivariate binomial data

Thank you. This was very helpfull.

Thierry 


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: Charles C. Berry [mailto:cberry at tajo.ucsd.edu] 
Verzonden: vrijdag 17 april 2009 21:31
Aan: ONKELINX, Thierry
CC: r-help at r-project.org
Onderwerp: Re: [R] Generate bivariate binomial data
On Fri, 17 Apr 2009, ONKELINX, Thierry wrote:

            
who
twice
likely
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
------------------------------------------------------------------------
more
to
not
schrijver weer
bevestigd is
message
as stating
by a duly
http://www.R-project.org/posting-guide.html
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



Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.