12.2 Normal Distribution

If we follow from previous chapters, our model looks like

Yi|β0,β1,β2,β3,σN(μi,σ2)

with

μi=β0+β1Xi1+β2Xi2+β3Xi3

12.2.1 Exploratory Data Visualization

ggplot(equality, aes(x = laws)) + 
  geom_histogram(color = "white", breaks = seq(0, 160, by = 10))

12.2.2 Outlier

# Identify the outlier
equality %>% 
  filter(laws == max(laws))
## # A tibble: 1 × 6
##   state      region gop_2016  laws historical percent_urban
##   <fct>      <fct>     <dbl> <dbl> <fct>              <dbl>
## 1 california west       31.6   155 dem                   95
# Remove the outlier
equality <- equality %>% 
  filter(state != "california")

12.2.3 Predictor Variables

ggplot(equality, aes(y = laws, x = percent_urban, color = historical)) + 
  geom_point(size = 3) +
  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()