# [R] simulation-binomial

Greg Snow Greg.Snow at intermountainmail.org
Wed Aug 8 20:37:58 CEST 2007

```Does this do what you want?

> x2 <- rbinom( 200, 1, ifelse(x, .95, p1/.6) )
> y2 <- rbinom( 300, 1, ifelse(y, .8, p1/.6) )

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> sigalit mangut-leiba
> Sent: Wednesday, August 08, 2007 11:18 AM
> To: r-help
> Subject: Re: [R] simulation-binomial
>
> I have the probability: P(T+ / D+)
> i want to find P(T+,D+) which is: P(T+ / D+)*P(D+) and i have
> those probabilities. i dont know how to write this in R.
> something like this: (say p2 is the conditional prob. and p1
> is the joint
> prob.)
>
> p2 <- p1/.6
> x <- rbinom(200, 1, .6)
> y <- rbinom(300, 1, .6)
> if (x) p2==0.95
> if (y) p2==0.80
>
> i don't know how to write the "if "condition.
> sigalit.
>
>
> On 8/8/07, Kyle Henderson <ambertk at ohsu.edu> wrote:
> >
> > That depends on what you meant by writing the conditional
> probability.
> > Bayes rule says that the probability of testing positive
> when one has
> > the disease is calculated as follows:
> >
> >      Pr(T+ | D+)=(Pr(D+ | T+)*Pr(T+))/Pr(D+)
> >
> > is that what you mean?
> >
> >
> > Kyle H. Ambert
> > Department of Behavioral Neuroscience
> > Oregon Health & Science University
> >
> >
> >
> >  On 8/8/07, sigalit mangut-leiba <smangut at gmail.com> wrote:
> >
> > > hello,
> > > i want to do a binomial simulation, by taking 200 var. from one
> > > group
> > > (x)
> > > and 300 from another (y).
> > > the prob. for disease=.6 in both groups.
> > >
> > > x <- rbinom(200, 1, .6)
> > >
> > > y <- rbinom(300, 1, .6)
> > > if the person is from group x - the probability to find
> the disease,
> > > assuming the person is sick, is .95, if he is from group
> Y its .80.
> > > i want to know the joint probability: p(the person has
> the disease
> > > and tested sick)=P(D+,T+).
> > > my problem is how to write the conditional prob.
> > > Thanks for your help, also reference on this subject (binomial
> > > simulation)
> > > would be great.
> > > Sigalit.
> > >
> > >         [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > >
> http://www.R-project.org/posting-guide.html<http://www.r-project.org
> > > /posting-guide.html> and provide commented, minimal,
> self-contained,
> > > reproducible code.
> > >
> >
> >
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help