extract.box: Extract boxes

Description Usage Arguments Details Value See Also Examples

View source: R/methods.R

Description

Extracts one or several boxes from a prim object.

Usage

1
extract.box(object, npeel = NULL, support = NULL, yfun = NULL, npaste = NULL)

Arguments

object

prim object.

npeel

Integer vector indicating which boxes to choose in object through the number of peeling iteration.

support

Numeric vector with values between 0 and 1 indicating the support of boxes to choose in object.

yfun

Numeric vector indicating the value of the objective function for the chosen boxes in object.

npaste

Integer vector indicating which boxes to choose in object through the number of pasting iteration.

Details

Returns one or several boxes from object. The boxes can be given through the number of peeling iterations (argument npeel), pasting iterations (argument npaste), closest support (argument support) or closest objective function value (argument yfun). Note that several of these arguments can be used at once to return several boxes. If no box matches the arguments or if they are all NULL, the last box in object is returned.

Value

A list with elements:

limits

A list giving the limits of extracted boxes. Each limit is a list with one element per input variable.

npeel

A vector giving the number of peeling iterations leading to each extracted box.

yfun

A vector giving the objective function value of each extracted box.

support

A vector giving the support of each extracted box.

See Also

peeling to perform the peeling and create a prim object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
   # 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 step
   peel_res <- peeling(y, x)
   # Extracting a single box
   single_box <- extract.box(peel_res, support = 0.1)
   # Extracting all boxes from a prim object
   all_boxes <- extract.box(peel_res, npeel = 0:peel_res$npeel)

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