12.5 Prior Distribution

Assuming these priors are independent.

Yi|β0,β1,β2,β3,σPois(λi)β0cN(2,0.52)β1N(0,0.172)β2N(0,4.972)β3N(0,5.602)

  • “typical state” λ=7

log(λ)=log(7)1.952

  • logged number of laws (2±2×0.5)

(e1,e3)(3,20)

prior_summary(equality_model_prior)
## Priors for model 'equality_model_prior' 
## ------
## Intercept (after predictors centered)
##  ~ normal(location = 2, scale = 0.5)
## 
## Coefficients
##   Specified prior:
##     ~ normal(location = [0,0,0], scale = [2.5,2.5,2.5])
##   Adjusted prior:
##     ~ normal(location = [0,0,0], scale = [0.17,4.97,5.60])
## ------
## See help('prior_summary.stanreg') for more details

12.5.1 So Far

equality %>% 
  add_fitted_draws(equality_model_prior, n = 100) %>%
  ggplot(aes(x = percent_urban, y = laws, color = historical)) +
    geom_line(aes(y = .value, group = paste(historical, .draw))) +
  labs(title = "Anti-Discrimination Laws",
       subtitle = "Human Rights Campaign State Equality Index",
       caption = "R4DS Bayes Rules book club") +
  scale_color_manual(values = c("blue", "red", "purple")) +
  theme_minimal() + 
    ylim(0, 100)