R/plot_st_residuals.R

Defines functions plot_st_residuals

Documented in plot_st_residuals

#' plot_st_residuals
#' Plots standardized and studentized residuals on one plot.
#' @export
plot_st_residuals <- function(model){
  
  res.df <- data.frame("fitted.vals" <- as.vector(model$fitted.values),
                       "standardized" = rstandard(model),
                       "studentized" = rstudent(model))
  names(res.df)[1] <- "fitted.vals"
  
  
  res.df %>%
    pivot_longer(cols = starts_with("s"), 
                 names_to = "type", values_to = "residuals") %>%
    group_by(type) %>%
    ggplot(aes(x = fitted.vals, y = residuals, color = type)) +
    geom_point() +
    facet_wrap(.~type)
}
cbreenmachine/wiscR documentation built on Jan. 26, 2022, 9:10 a.m.