How many Swedish candy boats (in total, both red and black) does the candy jar contain? Pair up in teams and try to build a Bayesian model that predicts this. Submit your prediction here before the time runs out (only one prediction per team!):
http://goo.gl/forms/10BZU3azOv
Hint 1: A good model for predicting this is probably going to be very similar to the capture re-capture model we used in the fish problem.
Hint 2: It might be easiest to start with a uniform prior over the number of candy boats in the jar. But if you have time, it might give your team an edge to experiment with more “informative” priors.
Hint 3: Below is some code scaffolding that you can use to kick-start your model. You will (at least) have to change the “…” parts.
# Number of random draws from the prior
n_draws <- 10000
prior <- ... # Here you sample n_draws draws from the prior
hist(prior) # It's always good to eyeball the prior to make sure it looks ok.
# Here you define the generative model
generative_model <- function(parameters) {
...
}
# Here you simulate data using the parameters from the prior and the
# generative model
sim_data <- rep(NA, n_draws)
for(i in 1:n_draws) {
sim_data[i] <- generative_model(prior[i])
}
# Here you filter off all draws that do not match the data.
posterior <- prior[sim_data == observed_data]
hist(posterior) # Eyeball the posterior
length(posterior) # See that we got enought draws left after the filtering.
# There are no rules here, but you probably want to aim
# for >1000 draws.
# Now you can summarize the posterior, where a common summary is to take the mean
# or the median posterior, and perhaps a 95% quantile interval.
median(posterior)
quantile(posterior, c(0.025, 0.975))