29.8 Examine Residuals

diamonds2 <- diamonds2 %>% 
  add_residuals(mod_diamond, "log_resid")

ggplot(diamonds2) +
  aes(log_carat, log_resid) +
  geom_hex(bins = 50)
base_plot <- ggplot(diamonds2) +
  aes(y = log_resid) + 
  geom_boxplot()

base_plot +
  aes(cut)

base_plot +
  aes(color)

base_plot +
  aes(clarity)