predict.prim: Predict method for a 'prim' object

Description Usage Arguments Value See Also Examples

View source: R/methods.R

Description

For each observation in newx, check if it is in selected boxes of object. Also gives the objective function values of each box based on the newy values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'prim'
predict(
  object,
  newx,
  newy,
  npeel = NULL,
  support = NULL,
  yfun = NULL,
  npaste = NULL,
  ...
)

Arguments

object

A prim object.

newx

A data.frame of new input values. If missing, uses object$x.

newy

A vector of new responses values corresponding to the inputs in newx. If missing, uses object$y.

npeel

Integer vector indicating which boxes in object to use for prediction, through the number of peeling iteration.

support

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

yfun

Numeric vector indicating the value of the objective function for the boxes in object to use for prediction.

npaste

Integer vector indicating which boxes in object to use for prediction, through the number of pasting iteration.

...

further arguments passed to or from other methods.

Value

A list with elements:

inbox

A logical matrix of dimension n x nboxes where n is the number of observations in newx. For each observation and each returns TRUE if the observation is inside the box.

support

A numeric vector giving, for each box, the proportion of observations in newx lying inside the box.

yfun

A numeric vector giving, for each box, the objective function value computed on newy.

See Also

peeling and pasting for creating prim objects.

Examples

1
2
3
4
5
6
7
8
   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)
   # Prediction
   predict(peel_res, newx = data.frame(x1 = 1:10/11, x2 = 1:10/11),
     newy = 1:10, support = c(1, 0.25))

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