res.diagnostics: Illustrate the results from residual analysis

View source: R/residdiagnostics.R

res.diagnosticsR Documentation

Illustrate the results from residual analysis

Description

At least seven plots can be produced in one panel. This function prints out a table with plots similar to the one generated by SAS as well as one by one diagram describing and analyzing the residuals from a linear regression.

Usage

res.diagnostics(
  lm_obj,
  block = F,
  outliers = F,
  normality = F,
  outnorm = T,
  regressors = F
)

Arguments

block

TRUE all the plots about the residuals will be in one panel.

outliers

TRUE only plots regarding the residuals will be produced in two scatter plots and a boxplot. The first scatter scatter plot is between the actual residuals from lm function and the fitted values. The second scatter plot it the studentized residuals vs the fitted values. The boxplot is from the studentized residuals.

normality

TRUE it will give an histogram of the residuals, a qq-plot of the residuals and a scatter plot between the fitted values and the the actual values of the dependent variable is also included.

outnorm

TRUE will give a panel with 6 diagrams for the residuals in outliers and in normality together.

regressors

TRUE one or more than one scatter plot regarding each independent variable and the residuals will be produced. For more than 9 regressors than it will produce one by one plot. If the independent variable is kvalitative, transform first as factor and than it will automatically produce a boxplot.

lmobject

a fitted regression model from lm. With only this argument the function will print out all the plots one by one.

Examples

library(regkurs)
lmfit = lm(nRides ~ temp + hum + windspeed, data = bike)
res.diagnostics(lmfit) #6 plots together
res.diagnostics(lmfit,block=T)#all the plots in one panel
res.diagnostics(lmfit,outliers=T)#only the first three plots regarding residuals, studentized residuals
res.diagnostics(lmfit,normality=T)#only three plots regarding normality and fitting
res.diagnostics(lmfit,outnorm = F)#all plots one by one
res.diagnostics(lmfit,regressors=T)#show only the relationship between the residuals and each regressor included in lm()

StatisticsSU/regkurs documentation built on Jan. 29, 2023, 4:54 p.m.