ggdiagnose: Graphically diagnose model residuals (ggplot2 version).

View source: R/ggdiagnose.R

ggdiagnoseR Documentation

Graphically diagnose model residuals (ggplot2 version).

Description

Graphically diagnose model residuals (ggplot2 version).

Usage

ggdiagnose(model, fit_type = 'response', residual_type = 'response', bins = 30, se = TRUE, freqpct = FALSE, alpha = 1)

Arguments

model

An lm or glm object.

fit_type

String. Default is "response". Type of fitted values to use based on options in predict().

residual_type

String. Default is "response". Type of residuals values to use based on options in resid().

bins

Number of bins to specify for histograms.

se

Boolean. For overlaying shaded standard errors.

freqpct

Boolean.

alpha

Integer, [0, 1]. Points are more transparent the closer they are to 0. Only applies to scatter plots.

Value

2 scatter plots and 2 histograms of residuals and "residuals margin," which is the residuals as a percentage of the actual dependent variable values.

See Also

https://github.com/robertschnitman/diagnoser

Examples


# OLS case
model <- lm(data = mtcars, formula = mpg ~ wt + gear)
ggdiagnose(model, bins = NROW(mtcars), se = FALSE, freqpct = TRUE)

# NLS case
model.nls <- nls(Ozone ~ theta0 + Temp^theta1, airquality)
ggdiagnose(model.nls)


robertschnitman/schnitr documentation built on Aug. 18, 2022, 8:39 p.m.