LoslegenKostenlos loslegen

Approximating the likelihood function

The first election poll is in! \(X\) = 6 of 10 polled voters plan to vote for you. You can use these data to build insight into your underlying support \(p\). To this end, you will use the likelihood_sim data frame (in your workspace). This contains the values of \(X\) (poll_result) simulated from each of 1,000 possible values of \(p\) between 0 to 1 (p_grid).

Diese Übung ist Teil des Kurses

Bayesian Modeling with RJAGS

Kurs anzeigen

Anleitung zur Übung

The ggplot() here constructs the distribution of \(p\) from which each possible outcome of \(X\) was generated. Modify this code, supplying a fill condition in order to highlight the distribution which corresponds to your observed poll_result, \(X=6\). This provides insight into which values of \(p\) are the most compatible with your observed poll data!

Note: do not wrap this condition in parentheses ().

Interaktive Übung

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

# Density plots of p_grid grouped by poll_result
ggplot(likelihood_sim, aes(x = p_grid, y = poll_result, group = poll_result, fill = ___)) + 
    geom_density_ridges()
Code bearbeiten und ausführen