plot.gofN: Plotting methods for 'gofN', making residual and...

plot.gofNR Documentation

Plotting methods for gofN, making residual and scale-location plots.

Description

The plot() method uses R graphics.

The ggplot2::autoplot() method uses ggplot2 and ggrepel.

Usage

## S3 method for class 'gofN'
plot(
  x,
  against = NULL,
  which = 1:2,
  col = 1,
  pch = 1,
  cex = 1,
  bg = 0,
  ...,
  ask = length(which) > 1 && dev.interactive(TRUE),
  id.n = 3,
  id.label = NULL,
  main = "{type} for {sQuote(name)}",
  xlab = NULL,
  ylim = NULL,
  cex.id = 0.75
)

## S3 method for class 'gofN'
autoplot(
  x,
  against = .fitted,
  which = 1:2,
  mappings = list(),
  geom_args = list(),
  id.n = 3,
  id.label = NULL
)

Arguments

x

a gofN object.

against

what the residuals should be plotted against. Note that different methods use different formats: see Details. Categorical (factor and ordered) values are visualised using boxplots, with ordered values also adding a smoothing line like the quantitative. Defaults to the fitted values.

which

which to plot (1 for residuals plot, 2 for \sqrt{|R_i|} scale plot, and 3 for normal quantile-quantile plot).

col, pch, cex, bg

vector of values (wrapped in I()), network attribute, or a formula whose RHS gives an expression in terms of network attributes to plot against.

...

additional arguments to plot(), qqnorm(), and qqline(), and others.

ask

whether the user should be prompted between the plots.

id.n

maximum number of extreme points to label explicitly.

id.label

specification for how extreme points are to be labeled, defaulting to network's index in the combined network.

main

a template for the plots' titles; these use glue()'s templating, with {type} replaced with the type of plot and {name} replaced with the statistic.

xlab

horizontal axis label; defaults to a character representation of against.

ylim

vertical range for the plots, interpreted as in graphics::plot(); can be specified as a list with 3 elements, giving the range for the corresponding plot according to the plot numbers for the ⁠which=⁠ argument, and can be used to ensure that, e.g., diagnostic plots for different models are on the same scale.

cex.id

scaling factor for characters used to label extreme points; see plot.lm().

mappings

a named list of lists of mappings constructed by ggplot2::aes() overriding the defaults. See Details below.

geom_args

a named list of lists of arguments overriding the defaults for the individual geoms. See Details below.

Details

For the plot() method, against and id.label can be vectors of values (enclosed in I() to be used as is), a character string identifying a network attribute, or a formula whose RHS gives an expression in terms of network attributes to plot against. The against formula may also contain a .fitted variable which will be substituted with the fitted values.

For autoplot.gofN(), against and id.label are interpreted as expressions in terms of network attributes and values generated by augment.gofN(), included .fitted for the fitted values.

Value

autoplot.gofN() returns a list of ggplot objects that if printed render to diagnostic plots. If there is only one, the object itself is returned.

Customising autoplot.gofN()

autoplot.gofN() constructs the plots out of ggplot2::ggplot(), ggplot2::geom_point() (for numeric against), ggplot2::geom_boxplot() for categorical or ordinal against), and ggplot2::geom_smooth() (for numeric or ordinal against), and ggrepel::geom_text_repel(). Mappings and arguments passed through mappings and geom_args override the respective defaults. They may have elements default (for ggplot()), point (for geom_point() and geom_boxplot()), smooth (for geom_smooth), and text (for geom_text_repel()).

See Also

gofN() for examples, plot.lm(), graphics::plot() for regression diagnostic plots and their parameters.


ergm.multi documentation built on May 29, 2024, 11:07 a.m.