How statistics can get me better results with this bootstrap experiment? I made a survey to ask people if they want to come back our meetup meetings after the fall of the covid cases and the reopening of the stores and schools in my city.
In the survey 64% of 25 people said they want to come back (16 people does and 9 people don't), I made a bootstrap with this which gave me a huge margin of error, I don't remember exactly but it was something around 15%.
I know around 100 people is the number of the potential guests who may go to the meetings. How can I shrink my margin of error using this information?
 A: There will be more elegant ways to solve this, and certainly people who know more about this then me, but let me try to answer that using a brute force simulation approach.
Please be gently with me if there is a mistake. I try to make small steps so eventual mistakes will hopefully be easy to spot.
I think that the number of potential visitors is 100 should help as we know, we already asked a fourth of the population. All values of less then 16 visitors bear no likelihood. That is more information then Agresti of Jeffries CI have.
Let's assume n out of 100 people plan to come back. For each of the possible n we will perform simulations in a function I call L. In L we repeatedly take a sample of size 25 of those 100 and ask them. What is chance/likelihood, that 16 of those 25 answer "yes"?
I think the following code does right that:
L <- function(n, N = 1e5){
  all <- c(rep("Yes", n), rep("no", 100-n))
  
  simulations <- replicate(N, {
    observed <- sample(all, size = 25)
    sum(observed == "Yes")  
  })
  return(sum(simulations==16)/N)
}


distribution <- data.frame(n = 10:100,
                           likelihood = sapply(10:100, L))

plot(distribution$n, distribution$likelihood) 

After so computation time it leads to a likelihood distribution:

The sum of these values is
> sum(distribution$likelihood)
[1] 3.89701

So to get proper probabilities we need to devide these values by 3.89 and if we want to go Bayes on it, we'd have to multiply it with our prior. I assume a flat prior and will only do division:
distribution$prob <- distribution$likelihood / sum(distribution$likelihood)
sum(distribution$prob)

We should now be able to build credible intervals from those probabilities
plot(distribution$n, cumsum(distribution$prob))
abline(h=c(.025, .975), lty=2)
abline(v=seq(45, 80, 5), col = "grey", lty=3)


This looks like a reasonable CI might range from 46 to 78 people planing to come back.
