flatworm: Flatworm plot for normalized quantile residuals

Description Usage Arguments See Also

View source: R/flatworm.R

Description

Generates a flattened version of a detrended normal Q-Q plot (a worm plot) for regression diagnostics.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
flatworm(object, ...)

## S3 method for class 'lm'
flatworm(object, cols = NULL, ...)

## S3 method for class 'map'
flatworm(object, cols = NULL, y = NULL, ...)

## S3 method for class 'map2stan'
flatworm(object, cols = NULL, y = NULL, ...)

## S3 method for class 'data.frame'
flatworm(object, residual_z, cols = NULL, ylim = 6,
  points = TRUE, lines = FALSE, loess = TRUE, cubic = FALSE,
  z_cubic = FALSE, ...)

Arguments

object

The object to generate diagnostics from, such as a model (for flatworm.lm, flatworm.map, ...) or a data frame of residuals (for flatworm.data.frame).

...

Additional arguments passed onto flatworm.data.frame by model-specific versions of flatworm.

Flatworm implements a variant of a worm plot (See e.g. wp). Unlike the traditional worm plot, its x-axis is scaled in units of standard errors. Thus the arcs that define ~ +-2 SE in a worm plot (the region most residuals should be within) instead define a band, making it a more straightforward task to judge whether the residuals are contained within +- 2 SE.

Model-specific versions of flatworm simply extract data and normalized residuals from a model and then pass them to flatworm.data.frame.

cols

Bare (unquoted) name of a column to facet over for generating multiple flatworm plots (i.e. small multiples). If cols is numeric, it will be split into quartiles; if is it a factor, into levels.

y

map2stan and map objects may contain multiple dependent variables; use y (as an unquoted expression) to specify the desired response to calculate residuals from (or NULL to use the first link function in the model).

residual_z

Bare name of the normalized residuals in object.

ylim

Limits of the y axis to plot. If a numeric vector of length 2, specifies min and max. If numeric vector of length 1, specifies abs(min) and max. If NA or NULL, the y limits are determined from the data.

points

Show residuals as points

lines

Show residuals as lines

loess

Show a loess fit to detrended residuals.

cubic

Show a cubic fit to detrended residuals.

z_cubic

Show a cubic fit to detrended residuals in z-space, translated onto the SE scale used by flatworm. This is the same fit used by wp displayed on the transformed y scale used by flatworm.

See Also

wp


mjskay/flatworm documentation built on May 23, 2019, 1:04 a.m.