Posterior probabilities
You've used RJAGS output to explore and quantify the posterior trend & uncertainty \(b\). You can also use RJAGS output to assess specific hypotheses. For example: What's the posterior probability that, on average, weight increases by more than 1.1 kg for every 1 cm increase in height? That is, what's the posterior probability that \(b > 1.1\)?
You will approximate this probability by the proportion of \(b\) Markov chain values that exceed 1.1. The weight_chains
data frame with the 100,000 iteration Markov chain output is in your workspace.
This exercise is part of the course
Bayesian Modeling with RJAGS
Exercise instructions
- Construct a density plot of the \(b\) Markov chain values and use
geom_vline()
to superimpose a vertical line at 1.1. - Use
table()
to summarize the number of \(b\) Markov chain values that exceed 1.1. - Use
mean()
to calculate the proportion of \(b\) Markov chain values that exceed 1.1.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Mark 1.1 on a posterior density plot for b
ggplot(___, aes(x = ___)) +
geom_density() +
geom_vline(xintercept = ___, color = "red")
# Summarize the number of b chain values that exceed 1.1
# Calculate the proportion of b chain values that exceed 1.1