29.9 Another Diamonds Model
mod_diamond2 <- lm(
log_price ~ log_carat + color + cut + clarity,
data = diamonds2
)
plot_mod2 <- function(parameter) {
grid <- diamonds2 %>%
data_grid({{parameter}}, .model = mod_diamond2) %>%
add_predictions(mod_diamond2)
ggplot(grid) +
aes(x = {{parameter}}, y = pred) +
geom_point()
}
plot_mod2(cut)
plot_mod2(color)
plot_mod2(clarity)