comparePlot-methods {RobAStBase} | R Documentation |
Compare - Plots
Description
Plots 2-4 influence curves to the same model.
Usage
comparePlot(obj1, obj2, ... )
## S4 method for signature 'IC,IC'
comparePlot(obj1, obj2, obj3 = NULL, obj4 = NULL, data = NULL,
..., withSweave = getdistrOption("withSweave"),
forceSameModel = FALSE, main = FALSE, inner = TRUE,
sub = FALSE, col = par("col"), lwd = par("lwd"), lty,
col.inner = par("col.main"), cex.inner = 0.8,
bmar = par("mar")[1], tmar = par("mar")[3],
with.automatic.grid = TRUE, with.legend = FALSE,
legend = NULL, legend.bg = "white",
legend.location = "bottomright", legend.cex = 0.8,
withMBR = FALSE, MBRB = NA, MBR.fac = 2, col.MBR = par("col"),
lty.MBR = "dashed", lwd.MBR = 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 = par("col"), 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,
withSubst = TRUE)
Arguments
obj1 |
object of class |
obj2 |
object of class |
obj3 |
optional: object of class |
obj4 |
optional: object of class |
data |
optional data argument — for plotting observations into the plot; |
withSweave |
logical: if |
forceSameModel |
logical; shall we check / enforce that the model
of the ICs |
main |
logical: is a main title to be used? or |
col |
color[s] of ICs in arguments |
lwd |
linewidth[s] of ICs in arguments |
lty |
line-type[s] of ICs in arguments |
inner |
logical: do panels have their own titles? or |
sub |
logical: is a sub-title to be used? or |
tmar |
top margin – useful for non-standard main title sizes |
bmar |
bottom margin – useful for non-standard sub title sizes |
cex.inner |
magnification to be used for inner titles relative
to the current setting of |
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 |
with.legend |
logical; shall a legend be plotted? |
legend |
either |
legend.location |
a valid argument |
legend.bg |
background color for the legend |
legend.cex |
magnification factor for the legend |
withMBR |
logical; shall horizontal lines with min and max of MBRE be plotted for comparison? |
MBRB |
matrix (or |
MBR.fac |
positive factor; scales the bounds given by argument |
col.MBR |
color for the MBR lines; as usual |
lty.MBR |
line type for the MBR lines; as usual |
lwd.MBR |
line width for the MBR lines; as usual |
x.vec |
a numeric vector of grid points to evaluate the influence curve;
by default, |
scaleX |
logical; shall X-axis be rescaled (by default according to the cdf of the underlying distribution)? |
scaleY |
logical; shall Y-axis be rescaled (by default according to a probit scale)? |
scaleX.fct |
an isotone, vectorized function mapping the domain of the IC
to [0,1]; if |
scaleX.inv |
the inverse function to |
scaleY.fct |
an isotone, vectorized function mapping for each coordinate the
range of the respective coordinate of the IC
to [0,1]; defaulting to the cdf of |
scaleY.inv |
an isotone, vectorized function mapping for each coordinate
the range [0,1] into the range of the respective coordinate of the IC;
defaulting to the quantile function of |
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 |
to.draw.arg |
Either |
withSubst |
logical; if |
col.pts |
color of the points of the |
pch.pts |
symbol of the points of the |
cex.pts |
size of the points of the |
cex.pts.fun |
rescaling function for the size of the points to be plotted;
either |
col.npts |
color of the non-labelled points of the |
pch.npts |
symbol of the non-labelled points of the |
cex.npts |
size of the non-labelled points of the |
cex.npts.fun |
rescaling function for the size of the non-labelled points
to be plotted; either |
lab.pts |
character or NULL; labels to be plotted to the observations;
can be a vector of length |
with.lab |
logical; shall labels be plotted to the observations?
(May be a vector of length |
cex.lbs |
size of the labels; can be vectorized to an array
of dim nlbs x |
col.lbs |
color of the labels; can be vectorized to a matrix
of dim nlbs x |
adj.lbs |
adjustment of the labels; can be vectorized to an array of
dim 2 x |
lab.font |
font to be used for labels (may be a vector of length
|
alpha.trsp |
alpha transparency to be added ex post to colors
|
jitter.fac |
jittering factor used in case of a |
attr.pre |
logical; do graphical attributes for plotted data refer
to indices prior ( |
which.lbs |
either an integer vector with the indices of the observations
to be plotted into graph or |
which.Order |
for each of the given ICs, we order the observations (descending)
according to the norm given by the corresponding |
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 |
return.Order |
logical; if |
... |
further arguments to be passed to |
Details
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:
"%C1"
,"%C2"
,["%C3"
,]["%C4"
]class of argument
obj<i>
, i=1,..4"%A1"
,"%A2"
,["%A3"
,]["%A4"
]deparsed argument
obj<i>
, i=1,..4"%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); in the case of longer length,
these are the values for ylim
for the plotted dimensions of the IC,
one pair for each dimension.
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)
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
References
Kohl, M. (2005) Numerical Contributions to the Asymptotic Theory of Robustness. Bayreuth: Dissertation.
See Also
L2ParamFamily-class
,
IC-class
, plot
Examples
if(require(ROptEst)){
N0 <- NormLocationScaleFamily(mean=0, sd=1)
N0.Rob1 <- InfRobModel(center = N0, neighbor = ContNeighborhood(radius = 0.5))
IC1 <- optIC(model = N0, risk = asCov())
IC2 <- optIC(model = N0.Rob1, risk = asMSE())
comparePlot(IC1,IC2)
set.seed(12); data <- r(N0)(20)
comparePlot(IC1, IC2, data=data, with.lab = TRUE,
which.lbs = c(1:4,15:20),
which.Order = 1:6,
return.Order = TRUE)
## don't test to reduce check time on CRAN
## selection of subpanels for plotting
par(mfrow=c(1,1))
comparePlot(IC1, IC2 ,mfColRow = FALSE, to.draw.arg=c("mean"),
panel.first= grid(),ylim=c(-4,4),xlim=c(-6,6))
## matrix-valued ylim
comparePlot(IC1, IC2, panel.first= grid(),ylim=c(-4,4,0,4),xlim=c(-6,6))
x <- c(data,-12,10)
comparePlot(IC1, IC2, data=x, which.Order=10,
panel.first= grid(), ylim=c(-4,4,0,4), xlim=c(-6,6))
Y <- Chisq(df=1)* DiscreteDistribution(c(-1,1))
comparePlot(IC1, IC2, data=x, which.Order=10,
scaleX = TRUE, scaleX.fct=pnorm, scaleX.inv=qnorm,
scaleY = TRUE, scaleY.fct=p(Y), scaleY.inv=q.l(Y),
panel.first= grid(), ylim=c(-4,4,0,4), xlim=c(-6,6))
comparePlot(IC1, IC2, data=x, which.Order=10,
scaleX = TRUE, scaleX.fct=pnorm, scaleX.inv=qnorm,
scaleY = TRUE, scaleY.fct=p(Y), scaleY.inv=q.l(Y),
x.ticks = c(-Inf, -10, -1,0,1,10,Inf),
y.ticks = c(-Inf, -5, -1,0,1,5,Inf),
panel.first= grid(), ylim=c(-4,4,0,4), xlim=c(-6,6))
## with use of trafo-matrix:
G <- GammaFamily(scale = 1, shape = 2)
## explicitely transforming to
## MASS parametrization:
mtrafo <- function(x){
nms0 <- names(c(main(param(G)),nuisance(param(G))))
nms <- c("shape","rate")
fval0 <- c(x[2], 1/x[1])
names(fval0) <- nms
mat0 <- matrix( c(0, -1/x[1]^2, 1, 0), nrow = 2, ncol = 2,
dimnames = list(nms,nms0))
list(fval = fval0, mat = mat0)}
G2 <- G
trafo(G2) <- mtrafo
G2
G2.Rob1 <- InfRobModel(center = G2, neighbor = ContNeighborhood(radius = 0.5))
system.time(IC1 <- optIC(model = G2, risk = asCov()))
system.time(IC2 <- optIC(model = G2.Rob1, risk = asMSE()))
system.time(IC2.i <- optIC(model = G2.Rob1, risk = asMSE(normtype=InfoNorm())))
system.time(IC2.s <- optIC(model = G2.Rob1, risk = asMSE(normtype=SelfNorm())))
comparePlot(IC1,IC2, IC2.i, IC2.s)
}