infoPlot {RobAStBase}R Documentation

Plot absolute and relative information

Description

Plot absolute and relative information of influence curves.

Usage

infoPlot(object,  ...)
## S4 method for signature 'IC'
infoPlot(object, data = NULL,
             ..., withSweave = getdistrOption("withSweave"),
             col = par("col"), lwd = par("lwd"), lty,
             colI = grey(0.5), lwdI = 0.7*par("lwd"), ltyI = "dotted",
             main = FALSE, inner = TRUE, sub = FALSE,
             col.inner = par("col.main"), cex.inner = 0.8,
             bmar = par("mar")[1], tmar = par("mar")[3],
             with.automatic.grid = TRUE,
             with.legend = TRUE, legend = NULL, legend.bg = "white",
             legend.location = "bottomright", legend.cex = 0.8,
             x.vec = NULL, scaleX = FALSE, scaleX.fct, scaleX.inv,
             scaleY = FALSE, scaleY.fct = pnorm, scaleY.inv=qnorm,
             scaleN = 9, x.ticks = NULL, y.ticks = NULL,
             mfColRow = TRUE, to.draw.arg = NULL,
             cex.pts = 1, cex.pts.fun = NULL, col.pts = par("col"),
             pch.pts = 19,
             cex.npts = 1, cex.npts.fun = NULL, col.npts = grey(.5),
             pch.npts = 20,
             jitter.fac = 1, with.lab = FALSE, cex.lbs = 1, adj.lbs = c(0, 0),
             col.lbs = col.pts, lab.pts = NULL, lab.font = NULL, alpha.trsp = NA,
             which.lbs = NULL, which.Order  = NULL, which.nonlbs = NULL,
             attr.pre = FALSE, return.Order = FALSE,
             ylab.abs = "absolute information",
             ylab.rel= "relative information",
             withSubst = TRUE)

Arguments

object

object of class "InfluenceCurve"

data

optional data argument — for plotting observations into the plot;

withSweave

logical: if TRUE (for working with Sweave) no extra device is opened

main

logical: is a main title to be used? or
just as argument main in plot.default.

inner

logical: do panels have their own titles? or
character vector of / cast to length 'number of compared dimensions'; if argument to.draw.arg is used, this refers to a vector of length 1 (absolute information) + length(to.draw.arg), the actually plotted relative informations. For further information, see also main in plot.default.

sub

logical: is a sub-title to be used? or
just as argument sub in plot.default.

tmar

top margin – useful for non-standard main title sizes; may be a vector with individual values for each of the panels to be plotted.

bmar

bottom margin – useful for non-standard sub title sizes; may be a vector with individual values for each of the panels to be plotted.

col

color of IC in argument object.

lwd

linewidth of IC in argument object.

lty

line-type of IC in argument object.

colI

color of the classically optimal IC.

lwdI

linewidth of the classically optimal IC.

ltyI

line-type of the classically optimal IC.

cex.inner

magnification to be used for inner titles relative to the current setting of cex; as in par.

col.inner

character or integer code; color for the inner title

with.automatic.grid

logical; should a grid be plotted alongside with the ticks of the axes, automatically? If TRUE a respective call to grid in argument panel.first is ignored.

with.legend

logical; shall a legend be plotted?

legend

either NULL or a list of length (number of plotted panels) of items which can be used as argument legend in command legend.

legend.location

a valid argument x for legend — the place where to put the legend on the last issued plot — or a list of length (number of plotted panels) of such arguments, one for each plotted panel.

legend.bg

background color for the legend

legend.cex

magnification factor for the legend

x.vec

a numeric vector of grid points to evaluate the influence curve; by default, x.vec is NULL; then the grid is produced automatically according to the distribution of the IC. x.vec can be useful for usage with a rescaling of the x-axis to avoid that the evaluation points be selected too unevenly (i.e. on an equally spaced grid in the original scale, but then, after rescaling non-equally). The grid has to be specified in original scale; i.e.; when used with rescaling, it should be chosen non-equally spaced.

scaleX

logical; shall X-axis be rescaled (by default according to the cdf of the underlying distribution)?

scaleY

logical; shall Y-axis be rescaled for abs.info-plot (by default according to a probit scale)?

scaleX.fct

an isotone, vectorized function mapping the domain of the IC to [0,1]; if scaleX is TRUE and scaleX.fct is missing, the cdf of the underlying observation distribution.

scaleX.inv

the inverse function to scale.fct, i.e., an isotone, vectorized function mapping [0,1] to the domain of the IC such that for any x in the domain, scaleX.inv(scaleX.fct(x))==x; if scaleX is TRUE and scaleX.inv is missing, the quantile function of the underlying observation distribution.

scaleY.fct

an isotone, vectorized function mapping the range of the norm of the IC to [0,1]; defaulting to the cdf of {\cal N}(0,1); can also be a list of functions with one list element for each of the panels to be plot.

scaleY.inv

an isotone, vectorized function mapping [0,1] into the range of the norm of the IC; defaulting to the quantile function of {\cal N}(0,1); can also be a list of functions with one list element for each of the panels to be plot.

scaleN

integer; defaults to 9; on rescaled axes, number of x and y ticks if drawn automatically;

x.ticks

numeric; defaults to NULL; (then ticks are chosen automatically); if non-NULL, user-given x-ticks (on original scale);

y.ticks

numeric; defaults to NULL; (then ticks are chosen automatically); if non-NULL, user-given y-ticks (on original scale); can be a list with one (numeric or NULL) item per panel

mfColRow

shall default partition in panels be used — defaults to TRUE

to.draw.arg

Either NULL (default; everything is plotted) or a vector making a selection among the relative information plots; the absolute information being plotted in any case. This vector is either a vector of integers (the indices of the subplots to be drawn) or characters — the names of the subplots to be drawn: these names are to be chosen either among the row names of the trafo matrix rownames(trafo(eval(object@CallL2Fam)@param)) or if the last expression is NULL a vector "dim<dimnr>", dimnr running through the number of rows of the trafo matrix.

withSubst

logical; if TRUE (default) pattern substitution for titles and lables is used; otherwise no substitution is used.

col.pts

color of the points of the data argument plotted; can be a vector or a matrix. More specifically, if argument attr.pre is TRUE, it is recycled to fill a matrix of dimension n by 2 (n the number of observations prior to any selection) where filling is done in order column first. The two columns are used for possibly different colors for the actual IC from the argument and the classical IC which is also shown. The selection done via which.lbs and which.Order is then done afterwards and on this matrix; argument col.npts is ignored in this case. If attr.pre is FALSE, col.pts is recycled to fill a matrix of dimension n.s by 2 where n.s is the number of observations selected for labelling and refers to the index ordering after the selection. Then argument col.npts deteremines the colors of the shown but non-labelled observations as given in argument which.nonlbs.

pch.pts

symbol of the points of the data argument plotted (may be a vector of length 2 or a matrix, see col.pts, with argument pch.npts as counterpart).

cex.pts

size of the points of the data argument plotted (may be a vector of length 2 or a matrix, see col.pts, with argument cex.npts as counterpart).

cex.pts.fun

rescaling function for the size of the points to be plotted; either NULL (default), then log(1+abs(x)) is used for each of the rescalings, or a function which is then used for each of the rescalings, or a list of functions; if it is a function or a list of functions, if necessary it is recylced to length 2 * dim where 2 is for the classical IC and the IC in argument object and dim is the number of dimensions of the pICs to be plotted; in the index of this list, 2 is incremented first; then dim.

col.npts

color of the non-labelled points of the data argument plotted; (may be a vector of length 2, or it can be a matrix nnlb <- sum(which.nonlbs) by 2, nnlb the number of non-labelled shown observations.

pch.npts

symbol of the non-labelled points of the data argument plotted (may be a vector of length 2 or a matrix, see col.npts).

cex.npts

size of the non-labelled points of the data argument plotted (may be a vector of length 2 or a matrix, see col.npts).

cex.npts.fun

rescaling function for the size of the non-labelled points to be plotted; either NULL (default), then log(1+abs(x)) is used for each of the rescalings, or a function which is then used for each of the rescalings, or a list of functions; if it is a function or a list of functions, if necessary it is recylced to length 2 * dim where dim is the number of dimensions of the pICs to be plotted; in the index of this list, 2 is incremented first; then dim.

attr.pre

logical; do graphical attributes for plotted data refer to indices prior (TRUE) or posterior to selection via arguments which.lbs, which.Order, which.nonlbs (FALSE)?

with.lab

logical; shall labels be plotted to the observations? (may be a vector of length 2, see col.pts – but not a matrix)

cex.lbs

size of the labels; can be vectorized to an array of dim nlbs x 2 x npnl where npnl is the number of plotted panels and nlbs the number of plotted labels; if it is a vector, it is recylced in order labels then ICs [arg IC/classic] then panels.

col.lbs

color of the labels; can be vectorized to a matrix of dim nlbs x 2 as col.pts.

adj.lbs

adjustment of the labels; can be vectorized to an array of dim 2 x 2 x npnl matrix, npnl the number of plotted panels; if it is a vector, it is recycled in order (x,y)-coords then ICs [arg IC/classic] then panels.

lab.pts

character or NULL; labels to be plotted to the observations; can be a vector of length n, n the number of all observations prior to any selection with which.lbs, which.Order; if lab.pts is NULL, observation indices are used.

lab.font

font to be used for labels; (may be a vector of length 2, see with.lab).

alpha.trsp

alpha transparency to be added ex post to colors col.pch and col.nonlbl; if one-dim and NA all colors are left unchanged. Otherwise, with usual recycling rules alpha.trsp gets shorted/prolongated to length the number of panel data-symbols to be plotted. Coordinates of this vector alpha.trsp with NA are left unchanged, while for the remaining ones, the alpha channel in rgb space is set to the respective coordinate value of alpha.trsp. The non-NA entries must be integers in [0,255] (0 invisible, 255 opaque).

jitter.fac

jittering factor used in case of a DiscreteDistribution for plotting points of the data argument in a jittered fashion (may be a vector of length 2, see with.lab).

which.lbs

either an integer vector with the indices of the observations to be plotted into graph or NULL — then no observation is excluded

which.Order

we order the observations (descending) according to the norm given by normtype(object); then which.Order either is an integer vector with the indices of the ordered observations (remaining after a possible reduction by argument which.lbs) to be plotted into graph or NULL — then no (further) observation is excluded.

which.nonlbs

indices of the observations which should be plotted but not labelled; either an integer vector with the indices of the observations to be plotted into graph or NULL — then all non-labelled observations are plotted.

return.Order

logical; if TRUE, a list of length two with order vectors is returned — one for ordering w.r.t. the given IC, one for ordering w.r.t. the classically optimal IC; more specifically, the order of the (remaining) observations given by their original index is returned (remaining means: after a possible reduction by argument which.lbs, and ordering is according to the norm given by normtype(object)); otherwise we return invisible() as usual.

ylab.abs

character; label to be used for y-axis in absolute information panel

ylab.rel

character; label to be used for y-axis in relative information panel

...

further parameters for plot

Details

Absolute information is defined as the square of the length of an IC. The relative information is defined as the absolute information of one component with respect to the absolute information of the whole IC; confer Section 8.1 of Kohl (2005).

Any parameters of plot.default may be passed on to this particular plot method.

For main-, inner, and subtitles given as arguments main, inner, and sub, top and bottom margins are enlarged to 5 resp. 6 by default but may also be specified by tmar / bmar arguments. If main / inner / sub are logical then if the respective argument is FALSE nothing is done/plotted, but if it is TRUE, we use a default main title taking up the calling arguments in case of main, default inner titles taking up the class and (named) parameter slots of arguments in case of inner, and a "generated on <data>"-tag in case of sub. Of course, if main / inner / sub are character, this is used for the title; in case of inner it is then checked whether it has correct length. If argument withSubst is TRUE, in all title and axis lable arguments, the following patterns are substituted:

"%C"

class of argument object

"%A"

deparsed argument object

"%D"

time/date-string when the plot was generated

If argument ... contains argument ylim, this may either be as in plot.default (i.e. a vector of length 2) or a vector of length 2*(number of plotted dimensions + e), where e is 1 or 0 depending on whether absolute information is plotted or not; in the case of longer length, if e is 1, the first two elements are the values for ylim in panel "Abs", while the last 2*(number of plotted dimensions) are the values for ylim for the plotted dimensions of the IC, one pair for each dimension.

Similarly, if argument ... contains arguments xaxt or yaxt, these may be vectorized, with one value for each of the panels to be plotted. This is useful for stacking panels over each other, using a common x-axis (see example below).

The ... argument may also contain an argument withbox which if TRUE warrants that even if xaxt and yaxt both are FALSE, a box is drawn around the respective panel.

In addition, argument ... may contain arguments panel.first, panel.last, i.e., hook expressions to be evaluated at the very beginning and at the very end of each panel (within the then valid coordinates). To be able to use these hooks for each panel individually, they may also be lists of expressions (of the same length as the number of panels and run through in the same order as the panels).

Value

An S3 object of class c("plotInfo","DiagnInfo"), i.e., a list containing the information needed to produce the respective plot, which at a later stage could be used by different graphic engines (like, e.g. ggplot) to produce the plot in a different framework. A more detailed description will follow in a subsequent version.

Author(s)

Matthias Kohl Matthias.Kohl@stamats.de

References

Kohl, M. (2005) Numerical Contributions to the Asymptotic Theory of Robustness. Bayreuth: Dissertation.

See Also

L2ParamFamily-class, IC-class

Examples

N <- NormLocationScaleFamily(mean=0, sd=1) 
IC1 <- optIC(model = N, risk = asCov())
infoPlot(IC1)

## don't run to reduce check time on CRAN

## selection of subpanels for plotting
par(mfrow=c(1,2))
infoPlot(IC1, mfColRow = FALSE, to.draw.arg=c("Abs","sd"))
infoPlot(IC1, mfColRow = FALSE, to.draw.arg=c("Abs","sd"), log="y")

infoPlot(IC1, mfColRow = FALSE, to.draw.arg=c("Abs","mean"), 
              panel.first= grid(), ylim = c(0,4), xlim = c(-6,6))
infoPlot(IC1, mfColRow = FALSE, to.draw.arg=c("Abs","mean"), 
              panel.first= grid(), ylim = c(0,4,-3,3), xlim = c(-6,6))

par(mfrow=c(1,3))
infoPlot(IC1, mfColRow = FALSE, panel.first= grid(),
         ylim = c(0,4,0,.3,0,.8), xlim=c(-6,6))
par(mfrow=c(1,1))

data <- r(N)(20)
par(mfrow=c(1,3))
infoPlot(IC1, data=data, mfColRow = FALSE, panel.first= grid(),
         with.lab = TRUE, cex.pts=2,
         which.lbs = c(1:4,15:20), which.Order = 1:6,
         return.Order = TRUE)
infoPlot(IC1, data=data[1:10], mfColRow = FALSE, panel.first= grid(),
         with.lab = TRUE, cex.pts=0.7)
par(mfrow=c(1,1))

ICr <- makeIC(list(function(x)sign(x),function(x)sign(abs(x)-qnorm(.75))),N)
data <- r(N)(600)
data.c <- c(data, 1000*data[1:30])
par(mfrow=c(3,1))
infoPlot(ICr, data=data.c, tmar=c(4.1,0,0), bmar=c(0,0,4.1),
         xaxt=c("n","n","s"), mfColRow = FALSE, panel.first= grid(),
         cex.pts=c(.9,.9), alpha.trsp=20, lwd=2, lwdI=1.5, col=3,
         col.pts=c(3,2), colI=2, pch.pts=c(20,20), inner=FALSE,
         scaleX = TRUE, scaleX.fct=pnorm, scaleX.inv=qnorm,
         scaleY=TRUE, scaleY.fct=function(x) pchisq(x,df=1),
         scaleY.inv=function(x)qchisq(x,df=1),legend.cex = 1.0)




[Package RobAStBase version 1.2.5 Index]