CommencerCommencer gratuitement

Updating the posterior

The posterior model of your underlying election support \(p\) is informed by both the prior model of \(p\) and polling data \(X\). Run the script to the right to remind yourself of the posterior that evolved from your original prior (Beta(45, 55)) and original poll data (\(X = 6\) of \(n = 10\) polled voters support you). The defined vote_model is in your workspace.

In a 3-step exercise, you will explore how using a different prior model or observing new data (or a combination of the two!) might impact the posterior.

Cet exercice fait partie du cours

Bayesian Modeling with RJAGS

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# COMPILE the model    
vote_jags <- jags.model(textConnection(vote_model), 
    data = list(a = 45, b = 55, X = 6, n = 10),
    inits = list(.RNG.name = "base::Wichmann-Hill", .RNG.seed = 100))

# SIMULATE the posterior
vote_sim <- coda.samples(model = vote_jags, variable.names = c("p"), n.iter = 10000)

# PLOT the posterior
plot(vote_sim, trace = FALSE, xlim = c(0,1), ylim = c(0,18))
Modifier et exécuter le code