Created
February 25, 2013 00:30
-
-
Save dmarcelinobr/5026475 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N < - 8619170 # population size of voters | |
ss <- c(1000, 1200, 3000) # samples size | |
p <- .27 # .27 Serra .25 Haddad .19 Russomano true population proportion | |
nsim <- 100 # number of simulations | |
pop.prob <- list() | |
for (i in 1:length(ss)) { | |
n <- ss[i] | |
x <- rhyper(nsim, N * p, N * (1 - p), n) | |
pop.prob[[i]] <- x / n | |
} | |
names(pop.prob) <- paste("n =", ss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment