Conditioning on the data (again)
Let's resurrect the zombie site example where you tested text ads. Out of a 100 impressions of the text ad, 6 out of a 100 clicked and visited your site.
To the right is roughly the code you developed in the last exercise. pars is currently the joint distribution over all combinations of proportion_clicks and n_visitors.
Este exercício faz parte do curso
Fundamentals of Bayesian Data Analysis in R
Instruções do exercício
- Condition on the data and keep only the rows in
parswheren_visitors == 6. - Normalize
pars$probabilityagain, to make sure it sums to1.0. - Plot the posterior
pars$probabilityusingplot(x = , y = , type = "h")withpars$proportion_clickson the x-axis andpars$probabilityon the y-axis.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
n_ads_shown <- 100
proportion_clicks <- seq(0, 1, by = 0.01)
n_visitors <- seq(0, 100, by = 1)
pars <- expand.grid(proportion_clicks = proportion_clicks,
n_visitors = n_visitors)
pars$prior <- dunif(pars$proportion_clicks, min = 0, max = 0.2)
pars$likelihood <- dbinom(pars$n_visitors,
size = n_ads_shown, prob = pars$proportion_clicks)
pars$probability <- pars$likelihood * pars$prior
pars$probability <- pars$probability / sum(pars$probability)
# Condition on the data
pars <- ___
# Normalize again
pars$probability <- ___
# Plot the posterior pars$probability
plot(___)