library(olsrr) library(dplyr) library(ggplot2) library(gridExtra) library(purrr) library(tibble) library(nortest) library(goftest)
olsrr offers tools for detecting violation of standard regression assumptions. Here we take a look at residual diagnostics. The standard regression assumptions include the following about residuals/errors:
Graph for detecting violation of normality assumption.
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) ols_plot_resid_qq(model)
Test for detecting violation of normality assumption.
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) ols_test_normality(model)
Correlation between observed residuals and expected residuals under normality.
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) ols_test_correlation(model)
It is a scatter plot of residuals on the y axis and fitted values on the x axis to detect non-linearity, unequal error variances, and outliers.
Characteristics of a well behaved residual vs fitted plot:
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) ols_plot_resid_fit(model)
Histogram of residuals for detecting violation of normality assumption.
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars) ols_plot_resid_hist(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.