LoslegenKostenlos loslegen

Change the model to use an informative prior

The code displayed is the old model you developed from scratch in chapter 2.

Diese Übung ist Teil des Kurses

Fundamentals of Bayesian Data Analysis in R

Kurs anzeigen

Anleitung zur Übung

  • Change this model to use the new informative prior for proportion_clicks that you just selected:
rbeta(n_draws, shape1 = 5, shape2 = 95)

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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))
Code bearbeiten und ausführen