Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section 4.5, broom::augment does not create .resid feature in the resulting data frame #71

Open
guidothekp opened this issue Apr 11, 2023 · 0 comments

Comments

@guidothekp
Copy link

Start with the following code from the section titled "Constant variance among residuals".

df1 <- broom::augment(cv_model1$finalModel, data = ames_train)

The code that follows from the page does not work:

p1 <- ggplot(df1, aes(.fitted, .resid)) + 
  geom_point(size = 1, alpha = .4) +
  xlab("Predicted values") +
  ylab("Residuals") +
  ggtitle("Model 1", subtitle = "Sale_Price ~ Gr_Liv_Area")

This is because .resid is not listed as a column in df1. This can be checked by invoking names(df1).

To fix this, I had to modify the following line to the first piece of code shown above -- I had to add the .resid column.

df1 <- broom::augment(cv_model1$finalModel, data = ames_train) %>%mutate(.resid = Sale_Price - .fitted)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant