Multilevel Probability Question
Yes, very rare For a simple random sample without replacement of 120 teachers from the 2000, the probability that every teacher comes from a different school is: # probs[k] is the probability that the kth drawn teacher is not from any of the previously drawn teacher's schools # and equals 1 - the probability that the teacher drawn IS from one of the previously drawn teacher's schools. # After drawing one teacher from a school there are 4 left from that schoold, so after drawing k-1 teachers there are 4*(k-1) teachers # out of 2000-k-1 teachers that could be drawn
probs<-1 - 4*(0:199)/(2000-0:199)
# The probability that all of the 120 teachers are from different schools is the product
prod(probs[1:120])
[1] 8.258304e-08 # picking 27 teachers from different schools is reasonably likely
prod(probs[1:27])
[1] 0.4861363
Rob
Chuck Cleland
<ccleland at optonli
ne.net> To
Sent by: "Martin Henry H. Stevens"
r-sig-mixed-model <stevenmh at muohio.edu>
s-bounces at r-proje cc
ct.org r-sig-mixed-models at r-project.org
Subject
Re: [R-sig-ME] Multilevel
06/12/2007 08:51 Probability Question
AM
Martin Henry H. Stevens wrote:
If you aren't stratifying by school, then isn't it just the probability of drawing 120 teachers out of 2000? -Hank
Creating the population described and taking a simple random sample of 120 teachers, it seems it would be very rare for no two teachers to come from the same school: pop <- data.frame(TEACHER = 1:2000, SCHOOL = rep(1:400, 5)) table(replicate(1000000, any(table(pop[sample(2000, size = 120, replace=FALSE),]$SCHOOL) > 1))) TRUE 1000000 There are obviously some samples where every teacher would come from a different school, but I'm not sure how you might find the specific probability. hope this helps, Chuck
On Jun 11, 2007, at 4:37 PM, Roberts, J. Kyle wrote:
Dear Friends,
I sent the following to the multilevel listserv, but thought that
some of you might actually have code to compute this in R. If you
do, please let me know.
I have an odd question. I am trying to compute the probability of
drawing 120 teachers from a sample of 2000 teachers in 400 schools
where no two teachers work at the same school. Assume that there
are 5 teachers at each school, evenly spread. I was trying to do
this with an "n choose k" type
situation, but I can't figure out how to include the part about
only 5 teachers can be at any given school. Any ideas? I am not
stratifying on school, just sampling teachers.
Thanks,
Kyle
***************************************
J. Kyle Roberts, Ph.D.
Baylor College of Medicine
Center for Educational Outreach
One Baylor Plaza, MS: BCM411
Houston, TX 77030-3411
713-798-6672 - 713-798-8201 Fax
jkrobert at bcm.edu
***************************************
[[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 _______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models