The first, and maybe the easiest, customizable option is the choice of plots to be displayed. The current available plots are (together with their corresponding numbers):
These plots can be chosen by giving a list of the numbers of the
wanted plots in the which
argument.
If the argument which
is not provided, then, by default,
the plots 1, 2, 5 and 6 will be displayed:
library(mixpoissonreg)
fit <- mixpoissonreg(daysabs ~ gender + math + prog | gender + math + prog,
data = Attendance)
plot(fit)
If we want only a single plot, we simply indicate its number. For
instance, if we only want the plot of Cook’s distances, we simply set
which = 3
:
If we want more than one, we provide a list with the desired plots.
Suppose we want the global influence-related plots, that is, plots 3, 4
and 5. Then, we set which = c(3,4,5)
:
In this section we will describe how to customize titles and subtitles.
First of all, by default, the type of the fitted model (that is, if it is a Negative-Binomial or Poisson Inverse Gaussian regression) is included in each caption. See, for instance, the plot below:
To remove the model type, simply set include.modeltype
to FALSE
:
One should notice that in both plots, the type of the residual was
only included in the y-axis label. To also include the type of
the residual at the caption, simply set
include.residualtype
to TRUE
:
One can define one common title to all plots by setting the
main
parameter to such common title. For instance,
The main
parameter also works to provide an additional
title to a single plot, by also setting the which
parameter
to the desired plot:
The captions (displayed above the plot) can be altered by setting the
caption
parameter to a list containing the wanted captions.
One drawback is that we have to provide a list containing the captions
we want in the positions of the plots we want. For example, if we only
have one plot, the following example will change the caption:
However, it will not work for the remaining plots, for instance:
A simple way to circumvent the above situation is to create an empty list and set the titles at the positions we want:
my_captions <- rep("",6)
my_captions[2] <- "My caption 2"
my_captions[4] <- "My caption 4"
plot(fit, which = c(2,4), caption = my_captions)
Notice that, since we did not change the
include.modeltype
argument, the model type are added in the
new captions.
We can change the size of the captions with the argument
cex.caption
. The default size is 1
. So, for
instance,
my_captions <- rep("",6)
my_captions[2] <- "My caption 2"
my_captions[4] <- "My caption 4"
plot(fit, which = c(2,4), caption = my_captions, cex.caption = 1.5)
We can also change the subcaption. By default, the subcaption is a
simplified version of the call to the mixpoissonreg
function that was used to fit the model.
We must have some caution on describing the subcaption. If each plot
is given in one window (without using the par(...)
command,
for example), then the subcaption is the caption below the
x-axis label. However, if multiple plots are given at once, and
there is space on the upper part of the plot, then the subcaption is a
general caption for all the plots.
We will illustrate the above description with examples to make it clearer.
The subcaption can be altered by setting the sub.caption
parameter to the desired caption.
Thus, we begin by providing the plots without the usage of
par
function.
Notice that the subcaption is below the x-axis label. The
same happens even if we there is more than one plot and we do not use
the par
function:
Now, notice the position of the subcaption when we gather multiple
plots using the par
function (while we provide room the
subcaption by using the oma
argument):
par(mfrow = c(2, 2), oma = c(0, 0, 2, 0), mar=par("mar")/2)
plot(fit, sub.caption = "My subcaption")
In the previous case, that is, the case in which we have the
subcaption above all plots, one can change the size of the subcaption
using the argument cex.oma.main
.
For instance,
In this section we show how to customize colors, sizes and types of lines and points.
First of all, notice that several graphical parameters may be passed
as additional parameters through the three dots ellipsis. For instance,
we may pass the argument pch
from plot.default
to change the type of points:
Another example is the main
color. Let us set a main
title with the main
argument, and change its color with the
col.main
argument:
We can also change the main
size, by using the
cex.main
argument:
Similarly, we can change the x and y label’s colors
by using the col.lab
argument:
As well as change their sizes by using the cex.lab
argument:
We can change the sub.caption
color by using the
col.sub
argument:
and change its size by using the cex.sub
argument:
Now, we deal with specific arguments of the
plot.mixpoissonreg
. We begin by dealing with the point
colors. To change the colors of the points, we use the
col.points
argument:
To change the point sizes, we use the argument
cex.points
:
We will now deal with point labels. First of all, we may change the
color of the point labels by using the argument col.id
:
We can change the point labels’ sizes by using the
cex.id
argument:
Let us now customize the lines in the Cook’s distance plots, namely
plots 3 and 4. By default, the line type for Cook’s distance plots is
'h'
:
Let us change the line type for Cook’s distance plots to points and change the point types to crosses:
Let us now change the colors of titles and captions. To change the
caption’s color, we use the col.caption
argument:
Finally, let us customize the quantile-quantile plots with and without simulated envelopes, namely, plot 2. The first customization is to remove the diagonal Q-Q line in the quantile-quantile plot without simulated envelopes:
We can change the qqline color by using the col.qqline
argument:
Finally, let us consider a fitting with simulated envelopes:
fit_env <- mixpoissonregML(daysabs ~ gender + math + prog | gender +
math + prog, envelope = 100, data = Attendance)
plot(fit_env, which = 2)
Let us first change the color of the lines of the upper and lower bands of the simulated envelopes:
Let us now change the color of the median curve of the simulated envelopes:
Let us also change the fill color of the simulated envelopes:
Let us change the color transparency. To such an end we use the
argument fill_alpha_env
:
By default the plot.mixpoissonreg
function always
identifies the 3 “most extreme” points. We can change it so that it does
not identify any points by setting the argument id.n
to
0:
We can also increase the number of identified points. For instance:
Finally, we can change the labels of the identified points with the
argument labels.id
. For instance, we may want to have the
value of the prog
covariate instead: