Learn R Programming

auditor (version 0.3.0)

plotResidual: Plot Residuals vs Observed, Fitted or Variable Values

Description

A plot of residuals against fitted values, observed values or any variable.

Usage

plotResidual(object, ..., variable = NULL, points = TRUE,
  lines = FALSE, std.residuals = FALSE, nlabel = 0)

Arguments

object

An object of class modelAudit or modelResiduals.

...

Other modelAudit objects to be plotted together.

variable

Only for modelAudit object. Name of model variable to order residuals. If value is NULL data order is taken. If value is "Predicted response" or "Fitted values" then data is ordered by fitted values. If value is "Observed response" the data is ordered by a vector of actual response (y parameter passed to the audit function).

points

Logical, indicates whenever observations should be added as points.

lines

Logical, indicates whenever smoothed lines should be added.

std.residuals

Logical, indicates whenever standardized residuals should be used.

nlabel

Number of observations with the biggest Cook's distances to be labeled.

See Also

plot.modelAudit

Examples

Run this code
# NOT RUN {
library(car)
lm_model <- lm(prestige~education + women + income, data = Prestige)
lm_au <- audit(lm_model, data = Prestige, y = Prestige$prestige)
plotResidual(lm_au)

library(randomForest)
rf_model <- randomForest(prestige~education + women + income, data = Prestige)
rf_au <- audit(rf_model, data = Prestige, y = Prestige$prestige)
plotResidual(lm_au, rf_au)

# }

Run the code above in your browser using DataLab