Exercise

# Simulating a Beta prior

Suppose you're running in an election for public office. Let \(p\) be your underlying support, the proportion of voters that plan to vote for you. Based on past polls, your prior model of \(p\) is captured by a Beta distribution with shape parameters 45 and 55.

You will approximate the Beta(45, 55) prior using random samples from the `rbeta()`

function. This function takes three arguments: sample size (`n`

) and two *shape* parameters (`shape1`

,`shape2`

). Subsequently, you will construct a density plot of the samples using `ggplot()`

. This function takes two arguments: the data set containing the samples and, within `aes()`

, the variable to be plotted on the `x`

axis. The density plot layer is added using `geom_density()`

.

Instructions

**100 XP**

- Use
`rbeta()`

to sample 10,000 draws from Beta(45, 55). Assign the output to`prior_A`

. - The
`prior_sim`

data frame includes the`prior_A`

sample. Apply`ggplot()`

to`prior_sim`

to construct a density plot of the prior samples.