linear_residuals: Assessment of Residuals in Linear Regression

View source: R/linear_residuals.R

linear_residualsR Documentation

Assessment of Residuals in Linear Regression

Description

This function is to examine residuals to assess for homoscedasticity and normality in a linear regression. This function allows for the examination of residuals of a bivariate linear regression or a multiple linear regression.

Usage

linear_residuals(
  data,
  x,
  y,
  se = c(TRUE, FALSE),
  alpha,
  size,
  line_size,
  color,
  line_color
)

Arguments

data

The data frame that includes the variables you are interested in examining in a linear regression.

x

Predictors to be included in your linear regression. You can either include one variable in quotations (e.g., "hp" from the mtcars dataset) or you can create an object of predictors (e.g., predictors <- c("disp", "cyl", "wt")).

y

Your outcome of interest in your linear regression. This variable does not require quotations.

se

A logical vector to decide if you'd like to include the standard error of your linear regression.

alpha

Value to determine how transparent you'd like your points in this function's plots.

size

Value to determine the size of the points in this function's plots. You can also determine if you'd like to assign these values to a categorical variable in your dataset.

line_size

Value to decide if you'd like your lines to be thinner or thicker in this function's plots.

color

Value to determine what color you'd like your points to be in this function's plots (e.g., "blue", "#6a1f25")

line_color

value to determine what color you'd like your lines to be in this function's plots (e.g., "blue", "#6a1f25")

Value

Returns two ggplot2 visuals showing the residuals in your model.

Examples


One Predictor
residual_view(data = mtcars, x = "hp", y = mpg, se = FALSE, alpha = .3, size = 2, line_size = 1, color = "blue", line_color = "dodgerblue")

predictors <- c("hp", "carb", "gear")
residual_view(data = mtcars, x = predictors, y = mpg, se = FALSE, alpha = .3, size = 2, line_size = 1, color = "blue", line_color = "dodgerblue")

jpedroza1228/reg.diagnostics documentation built on June 15, 2022, 9:30 p.m.