plotSimDiags {DAAG}R Documentation

Diagnostic plots for simulated data

Description

This provides diagnostic plots, closely equivalent to those provided by plot.lm, for simulated data. By default, simulated data are for the fitted model. Alternatively, simulated data can be supplied, making it possible to check the effct of fitting, e.g., an AR1 model.

Usage

plotSimDiags(obj, simvalues = NULL, seed = NULL,
types = NULL, which = c(1:3, 5), layout = c(4, 1), qqline=TRUE,
cook.levels = c(0.5, 1), caption = list("Residuals vs Fitted",
"Normal Q-Q", "Scale-Location", "Cook's distance", "Residuals vs Leverage",
expression("Cook's dist vs Leverage  " * h[ii]/(1 - h[ii]))),
...)

Arguments

obj

Fitted model object - lm or an object inheriting from lm

simvalues

Optional matrix of simulated data.

seed

Random number seed - set this to make results repeatable.

types

If set, this should be a list with six elements, ordinarily with each list element either "p" or c("p","smooth") or (which=2, which=6) NULL or (which=4) "h"

which

Set to be a subset of the numbers 1 to 6, as for plot.lm

layout

Controls the number of simulations and the layout of the plots. For example layout=c(3,4) will give 12 plots in a 3 by 4 layout.

qqline

logical: add line to normal Q-Q plot

cook.levels

Levels of Cook's statistics for which contours are to be plotted.

caption

list: Captions for the six graphs

...

Other parameters to be passed to plotting functions

Details

Diagnotic plots from repeated simulations from the fitted model provide a useful indication of the range of variation in the model diagnistics that are consistent with the fitted model.

Value

A list of lattice graphics objects is returned, one for each value of which. List elements for which a graphics object is not returned are set to NULL. Or if which is of length 1, a lattice graphics object.

residVSfitted

Residuals vs fitted

normalQQ

Normal quantile-quantile plot

scaleVSloc

Scale versus location

CookDist

Cook's distance vs observation number

residVSlev

Standardized residuals (for GLMs, standardized Pearson residuals) vs leverage

CookVSlev

Cook's distance vs leverage

For the default which=c(1:3,5), list items 1, 2, 3 and 5 above contain graphics objects, with list elements 4 and 6 set to NULL.

Note

The graphics objects contained in individual list elements can be extracted for printing, or updating and printing, as required. If the value is returned to the command line, list elements that are not NULL will be printed in turn.

Author(s)

John Maindonald, with some code chunks adapted from plot.lm

References

See plot.lm

See Also

plot.lm, lmdiags

Examples

women.lm <- lm(height ~ weight, data=women)
gphlist <- plotSimDiags(obj=women.lm, which=c(1:3,5))

[Package DAAG version 1.25.6 Index]