Last data update: 2014.03.03

R: Plots a standardaized residual
residualplot.defaultR Documentation

Plots a standardaized residual

Description

Plots a standardized residual plot from an lm object and provides additional graphics to help evaluate the variance homogeneity and mean.

Usage

## Default S3 method:
residualplot(x, y = NULL, candy = TRUE, bandwidth = 0.3,
  xlab = "Fitted values", ylab = "Std.res.", col.sd = "blue",
  col.alpha = 0.3, ...)

## S3 method for class 'lm'
residualplot(x, y, candy = TRUE, bandwidth = 0.3,
  xlab = "Fitted values", ylab = "Stud.res.", col.sd = "blue",
  col.alpha = 0.3, ...)

residualplot(x, y = NULL, candy = TRUE, bandwidth = 0.3,
  xlab = "Fitted values", ylab = "Std.res.", col.sd = "blue",
  col.alpha = 0.3, ...)

Arguments

x

lm object or a numeric vector

y

numeric vector for the y axis values

candy

logical. Should a lowess curve and local standard deviation of the residual be added to the plot. Defaults to TRUE

bandwidth

The width of the window used to calculate the local smoothed version of the mean and the variance. Value should be between 0 and 1 and determines the percentage of the window width used

xlab

x axis label

ylab

y axis label

col.sd

color for the background residual deviation

col.alpha

number between 0 and 1 determining the transprency of the standard deviation plotting color

...

Other arguments passed to the plot function

Details

Plots a standardized residual plot from an lm object and provides additional graphics to help evaluate the variance homogeneity and mean.

The brown area is a smoothed estimate of 1.96*SD of the standardized residuals in a window around the predicted value. The brown area should largely be rectangular if the standardized residuals have more or less the same variance.

The dashed line shows the smoothed mean of the standardized residuals and should generally follow the horizontal line through (0,0).

Value

Produces a standardized residual plot

Author(s)

Claus Ekstrom <claus@rprimer.dk>

See Also

rstandard, predict

Examples


# Linear regression example
data(trees)
model <- lm(Volume ~ Girth + Height, data=trees)
residualplot(model)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MESS)
Loading required package: geepack

Attaching package: 'MESS'

The following object is masked from 'package:stats':

    power.t.test

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MESS/residualplot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: residualplot.default
> ### Title: Plots a standardaized residual
> ### Aliases: residualplot residualplot.default residualplot.lm
> ### Keywords: hplot
> 
> ### ** Examples
> 
> 
> # Linear regression example
> data(trees)
> model <- lm(Volume ~ Girth + Height, data=trees)
> residualplot(model)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>