Produces a 3x3 grid of residual- or qq-plots plots from a lm object. One of the nine subfigures is the true residual plot/qqplot while the remaining are plots that fulfill the assumptions of the linear model

1 2 3 4 5 6 7 8 9 10 | ```
## Default S3 method:
wallyplot(x, y = x, FUN = residualplot, hide = TRUE,
simulateFunction = rnorm, ...)
## S3 method for class 'lm'
wallyplot(x, y = x, FUN = residualplot, hide = TRUE,
simulateFunction = rnorm, ...)
wallyplot(x, y = x, FUN = residualplot, hide = TRUE,
simulateFunction = rnorm, ...)
``` |

`x` |
a numeric vector of x values, or an lm object. |

`y` |
a numeric vector of y values of the same length as x or a n * 9 matrix of y values - one column for each of the nine plots to make. The first column is the one corresponding to the results from the dataset |

`FUN` |
a function that accepts an |

`hide` |
logical; if |

`simulateFunction` |
The function used to produce y values under the null hypothesis. Defaults to rnorm |

`...` |
Other arguments passed to the plot function |

Users who look at residual plots or qqnorm plots for the first time often feel they lack the experience to determine if the residual plot is okay or if the model assumptions are indeed violated. One way to convey "experience" is to plot a series of graphical model validation plots simulated under the model assumption together with the corresponding plot from the real data and see if the user can pinpoint one of them that looks like an odd-one-out. If the proper plot from the real data does not stand out then the assumptions are not likely to be violated.

The Wallyplot produces a 3x3 grid of plots from a lm object or from a set of pairs of x and y values. One of the nine subfigures is the true plot while the remaining are plots that fulfill the assumptions of the linear model. After the user interactively hits a key the correct residual plot (correponding to the provided data) is shown.

The plotting function can be set using the `FUN`

argument which should
be a function that accepts `x`

, `y`

and `...`

arguments and
plots the desired figure. When `y`

is a single vector the same length
as `x`

then the function `simulateFunction`

is used to generate
the remaining y values corresponding the situations under the null.

Claus Ekstrom claus@rprimer.dk

Ekstrom, CT (2014) *Teaching 'Instant Experience' with
Graphical Model Validation Techniques*. Teaching Statistics (36), p 23-26

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
data(trees)
res <- lm(Volume ~ Height + Girth, data=trees)
wallyplot(res)
# Create a grid of QQ-plot figures
# Define function to plot a qq plot with an identity line
qqnorm.wally <- function(x, y, ...) { qqnorm(y, ...) ; abline(a=0, b=1) }
wallyplot(res, FUN=qqnorm.wally, main="")
# Define function to simulate components+residuals for Girth
cprsimulate <- function(n) {rnorm(n)+trees$Girth}
# Create the cpr plotting function
cprplot <- function(x, y, ...) {plot(x, y, pch=20, ...) ;
lines(lowess(x, y), lty=3)}
# Create the Wallyplot
wallyplot(trees$Girth, trees$Girth+rstudent(res), FUN=cprplot,
simulateFunction=cprsimulate, xlab="Girth")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.