Closed mchien20 closed 6 years ago
I used broom in this commit: https://github.com/Amherst-Statistics/IS5inR/commit/de258ed94866de545c0d297e2d839a2936de21e6 However, I can't seem to get the parallel slopes to work.
@shukryzablah can you please check in on this front?
Is this what we want?:
library(readr)
library(mosaic)
library(janitor)
library(broom)
Diamonds <- read_csv(
"http://nhorton.people.amherst.edu/is5/data/Diamonds.csv"
) %>%
clean_names()
diamondlm <- lm(sqrt(price) ~ carat_size + color, data = Diamonds)
augmentedMod <- augment(diamondlm)
gf_point(sqrt.price. ~ carat_size, data = augmentedMod, color = ~ color) %>%
gf_line(.fitted ~ carat_size)
Created on 2018-07-06 by the reprex package (v0.2.0).
In Chapter 9, page 294, there's a visualization with parallel slopes and one that isn't. gf_lm() automatically adds the interaction into the model. I looked at Bonnie's code for parallel slopes, but since there are 8 levels, I am looking for a simpler way to do it. Here's the model: library(readr) library(mosaic) library(janitor) Diamonds <- read_csv("http://nhorton.people.amherst.edu/is5/data/Diamonds.csv") %>% clean_names() diamondlm <- lm(sqrt(price) ~ carat_size + color, data = Diamonds) msummary(diamondlm)