plot_predictions_vs_residuals | R Documentation |
A predictors vs residuals plot is useful for visually inspecting if a linear regression model violates both the Linear and Equal Variance assumptions of its residuals. The plot plots predicted values on the x-axis and residuals on the y-axis. If the resulting scatterplot shows a discernible pattern, then either or both of the assumptions are likely violated.
plot_predictions_vs_residuals(.data, .hline = "dashed")
## S3 method for class 'data.frame'
plot_predictions_vs_residuals(.data, .hline = "dashed")
.data |
The output of |
.hline |
(Optional) The |
A ggplot
object.
Kutner, M., Nachtsheim, C., Neter, J. and Li, W. (2005). Applied Linear Statistical Models. ISBN: 0-07-238688-6. McGraw-Hill/Irwin.
calculate_residuals()
library(tidytest)
mod_lm_fit <- lm(mpg ~ disp + wt + hp, data = mtcars)
pred_vs_resid_tbl <- calculate_residuals(mod_lm_fit)
plot_predictions_vs_residuals(pred_vs_resid_tbl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.