plot_box: Plot a box

Description Usage Arguments Details See Also Examples

View source: R/plots.R

Description

Plots a bidimensional projection of the data and chosen boxes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plot_box(
  object,
  select = 1:2,
  npeel = NULL,
  support = NULL,
  yfun = NULL,
  npaste = NULL,
  ypalette = NULL,
  box.args = list(),
  ...
)

Arguments

object

A 'prim' object.

select

A vector of length 1 or 2 indicating the input variables(s) to plot. Default to the two first ones. If a single variable is selected, plot it against y.

npeel

Integer vector indicating the number of peeling iteration of boxes to plot.

support

Numeric vector with values between 0 and 1 indicating the support of boxes to plot.

yfun

Numeric vector indicating the value of the objective function of the boxes to plot.

npaste

Integer vector indicating the number of pasting iteration of boxes to plot.

ypalette

A palette of colors for representing the y value associated to each point.

box.args

A list of arguments to be passed to rect for drawing boxes. All arguments can be given as vectors to specify different values for each drawn box.

...

Additional graphical parameters for plot.

Details

Several boxes can be displayed at once, selected by one of the arguments npeel, support, yfun or npaste (when relevant). Note that the arguments in box.args allow giving different parameters to each displayed box.

See Also

peeling for peeling trajectories.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
   # A simple bump
   set.seed(12345)
   x <- matrix(runif(2000), ncol = 2, dimnames = list(NULL, c("x1", "x2")))
   y <- 2 * x[,1] + 5 * x[,2] + 10 * (x[,1] >= .8 & x[,2] >= .5) + 
     rnorm(1000)
   # Peeling with alpha = 0.05 and beta.stop = 0.05
   peel_res <- peeling(y, x, beta.stop = 0.05)
   # Automatically choose the best box
   chosen <- jump.prim(peel_res)
   # Plot the resulting box
   plot_box(peel_res, pch = 16, ypalette = hcl.colors(10), 
     support = chosen$final.box$support, box.args = list(lwd = 2))

PierreMasselot/primr documentation built on Feb. 5, 2021, 7:33 p.m.