This function provides ggplot2-based counterparts to the plots produced by plot.mixpoissonreg. Currently there are six plots available. They contain residual analysis and global influence diagnostics. The plots are selectable by the which argument. The plots are: Residuals vs. obs. numbers; Normal Q-Q plots, which may contain simulated envelopes, if the fitted object has simulated envelopes; Cook's distances vs. obs. numbers; Generalized Cook's distances vs. obs. numbers; Cook's distances vs. Generalized Cook's distances; Response variables vs. fitted means. By default, the first two plots and the last two plots are provided.

If both ncol and nrow are NULL, the plots will be placed one at a time. To place multiple plots, set the values for nrow or ncol.

# S3 method for mixpoissonreg
autoplot(
  object,
  which = c(1, 2, 5, 6),
  title = list("Residuals vs Obs. number", "Normal Q-Q", "Cook's distance",
    "Generalized Cook's distance", "Cook's dist vs Generalized Cook's dist",
    "Response vs Fitted means"),
  title.bold = FALSE,
  title.size = NULL,
  title.colour = NULL,
  label.repel = TRUE,
  x.axis.col = NULL,
  y.axis.col = NULL,
  x.axis.size = NULL,
  y.axis.size = NULL,
  cook.plot.type = "linerange",
  cook.plot.pointshape = NULL,
  nrow = NULL,
  ncol = NULL,
  qqline = TRUE,
  ask = prod(graphics::par("mfcol")) < length(which) && grDevices::dev.interactive(),
  include.modeltype = TRUE,
  include.residualtype = FALSE,
  sub.caption = NULL,
  sub.caption.col = NULL,
  sub.caption.size = NULL,
  sub.caption.face = NULL,
  sub.caption.hjust = 0.5,
  env_alpha = 0.5,
  env_fill = "grey70",
  gpar_sub.caption = list(fontface = "bold"),
  colour = "#444444",
  size = NULL,
  linetype = NULL,
  alpha = NULL,
  fill = NULL,
  shape = NULL,
  label = TRUE,
  label.label = NULL,
  label.colour = "#000000",
  label.alpha = NULL,
  label.size = NULL,
  label.angle = NULL,
  label.family = NULL,
  label.fontface = NULL,
  label.lineheight = NULL,
  label.hjust = NULL,
  label.vjust = NULL,
  label.n = 3,
  ad.colour = "#888888",
  ad.linetype = "dashed",
  ad.size = 0.2,
  ...
)

Arguments

object

A mixpoissonreg object.

which

a list or vector indicating which plots should be displayed. If a subset of the plots is required, specify a subset of the numbers 1:6, see title below for the different kinds. In plot number 2, 'Normal Q-Q', if the mixpoissonreg object was fitted with envelopes, a quantile-quantile plot with simulated envelopes will be displayed.

title

titles to appear above the plots; character vector or list of valid graphics annotations. Can be set to "" to suppress all titles.

title.bold

logical indicating whether the titles should be bold. The default is FALSE.

title.size

numerical indicating the size of the titles.

title.colour

title colour.

label.repel

Logical flag indicating whether to use ggrepel to place the labels.

x.axis.col

colour of the x axis title.

y.axis.col

colour of the y axis title.

x.axis.size

size of the x axis title.

y.axis.size

size of the y axis title.

cook.plot.type

character indicating the type of plot for Cook's distance and generalized Cook's distance. Default is "linerange". The options are "linerange" and "points".

cook.plot.pointshape

the shape of points if "cook.plot.type" is set to "points".

nrow

Number of facet/subplot rows. If both nrow and ncol are NULL, the plots will be placed one at a time. For multiple plots, set values for nrow or ncol.

ncol

Number of facet/subplot columns. If both nrow and ncol are NULL, the plots will be placed one at a time. For multiple plots, set values for nrow or ncol.

qqline

logical; if TRUE and the fit does not contain simulated envelopes, a qqline passing through the first and third quartiles of a standard normal distribution will be added to the normal Q-Q plot.

ask

logical; if TRUE, the user is asked before each plot.

include.modeltype

logical. Indicates whether the model type ('NB' or 'PIG') should be displayed on the titles.

include.residualtype

local. Indicates whether the name of the residual ('Pearson' or 'Score') should be displayed on the title of plot 1 (Residuals vs. Index).

sub.caption

common title-above the figures if there are more than one. If NULL, as by default, a possible abbreviated version of deparse(x$call) is used.

sub.caption.col

color of subcaption (when one figure at a time).

sub.caption.size

size of subcaption (when one figure at a time).

sub.caption.face

font face for subcaption, options are: "plain", "bold", "italic" and "bold.italic".

sub.caption.hjust

indicates the position of the subcaption (when one figure at a time). The default is 0.5, which indicates that the subcaption is centered, a value 0 places the subcaption at the left side of the plot whereas a value of 1 places the subcaption at the right side of the plot.

env_alpha

alpha of the envelope region (when the fitted model has envelopes)

env_fill

the colour of the filling in the envelopes.

gpar_sub.caption

list of gpar parameters to be used as common title in the case of multiple plots. The title will be given in sub.caption argument. See the help of gpar function from the grid package for all the available options.

colour

line colour.

size

point size.

linetype

line type.

alpha

alpha of the plot.

fill

fill colour.

shape

point shape.

label

Logical value whether to display labels.

label.label

vector of labels. If NULL, rownames will be used as labels.

label.colour

Colour for text labels.

label.alpha

Alpha for text labels.

label.size

Size for text labels.

label.angle

Angle for text labels.

label.family

Font family for text labels.

label.fontface

Fontface for text labels.

label.lineheight

Lineheight for text labels.

label.hjust

Horizontal adjustment for text labels.

label.vjust

Vertical adjustment for text labels.

label.n

Number of points to be laeled in each plot, starting with the most extreme.

ad.colour

Line colour for additional lines.

ad.linetype

Line type for additional lines.

ad.size

Fill colour for additional lines.

...

other arguments passed to methods.

Value

Called for its side effects.

Details

Based on autoplot.lm from the excellent ggfortify package, ggfortify.

sub.caption - by default the function call - is shown as a subtitle (under the x-axis title) on each plot when plots are on separate pages, or as a subtitle in the outer margin when there are multiple plots per page.

Examples

# \donttest{ data("Attendance", package = "mixpoissonreg") daysabs_fit <- mixpoissonreg(daysabs ~ gender + math + prog | gender + math + prog, data = Attendance) autoplot(daysabs_fit, which = 1:6)
autoplot(daysabs_fit, nrow = 2)
daysabs_fit_ml <- mixpoissonregML(daysabs ~ gender + math + prog | gender + math + prog, data = Attendance, envelope = 100) autoplot(daysabs_fit_ml, which = 2)
# } daysabs_prog <- mixpoissonregML(daysabs ~ prog, data = Attendance) autoplot(daysabs_prog)