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.
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]))),
...)
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.
Residuals vs fitted
Normal quantile-quantile plot
Scale versus location
Cook's distance vs observation number
Standardized residuals (for GLMs, standardized Pearson residuals) vs leverage
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
.
Fitted model object - lm
or an object inheriting from lm
Optional matrix of simulated data.
Random number seed - set this to make results repeatable.
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"
Set to be a subset of the numbers 1 to 6, as for plot.lm
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.
logical: add line to normal Q-Q plot
Levels of Cook's statistics for which contours are to be plotted.
list: Captions for the six graphs
Other parameters to be passed to plotting functions
John Maindonald, with some code chunks adapted from plot.lm
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.
See plot.lm
plot.lm
, lmdiags
women.lm <- lm(height ~ weight, data=women)
gphlist <- plotSimDiags(obj=women.lm, which=c(1:3,5))
Run the code above in your browser using DataLab