Pas het model aan om een informatieve prior te gebruiken
De getoonde code is het oude model dat je vanaf nul hebt opgebouwd in hoofdstuk 2.
Deze oefening maakt deel uit van de cursus
Basisprincipes van Bayesiaanse data-analyse in R
Oefeninstructies
- Pas dit model aan zodat het de nieuwe informatieve prior voor
proportion_clicksgebruikt die je zojuist hebt gekozen:
rbeta(n_draws, shape1 = 5, shape2 = 95)
Interactieve oefening met praktijkervaring
Probeer deze oefening door deze voorbeeldcode aan te vullen.
n_draws <- 100000
n_ads_shown <- 100
# Change the prior on proportion_clicks
proportion_clicks <-
runif(n_draws, min = 0.0, max = 0.2)
n_visitors <-
rbinom(n_draws, size = n_ads_shown,
prob = proportion_clicks)
prior <-
data.frame(proportion_clicks, n_visitors)
posterior <-
prior[prior$n_visitors == 13, ]
# This plots the prior and the posterior in the same plot
par(mfcol = c(2, 1))
hist(prior$proportion_clicks,
xlim = c(0, 0.25))
hist(posterior$proportion_clicks,
xlim = c(0, 0.25))