Skip to contents

S3 methods PRIM for multivariate data.

Usage

# S3 method for class 'prim'
predict(object, newdata, y.fun.flag=FALSE, ...)
# S3 method for class 'prim'
summary(object, ..., print.box=FALSE)

Arguments

object

object of class prim

newdata

data matrix

y.fun.flag

flag to return y value of PRIM box rather than box label. Default is FALSE.

print.box

flag to print out limits of all PRIM boxes. Default is FALSE.

...

other parameters

Details

–The predict method returns the value of PRIM box number in which newdata are located.

–The summary method displays a table with three columns: box-fun is the y value, box-mass is the mass of the box, threshold.type is the threshold direction indicator: 1 = ">= threshold", -1 = "<=threshold". Each box corresponds to a row. The second last row marked with an asterisk is the box which collates the remaining data points not belonging to a specific PRIM box. The final row is an overall summary, i.e. box-fun is the overall mean of y and box-mass is 1.

Examples

data(quasiflow)
qf <- quasiflow[1:1000,1:2]
qf.label <- quasiflow[1:1000,3]*quasiflow[1:1000,4]

qf.prim <- prim.box(x=qf, y=qf.label, threshold=c(0.3, -0.1), threshold.type=0)
summary(qf.prim)
#>             box-fun box-mass threshold.type
#> box1     0.39975894    0.131              1
#> box2     0.17537930    0.109              1
#> box3     0.38370978    0.052              1
#> box4    -0.13063967    0.087             -1
#> box5*   -0.01793194    0.621             NA
#> overall  0.06893629    1.000             NA
#> 
predict(qf.prim, newdata=c(0.6,0.2))
#> [1] 2

## using median insted of mean for the response y
qf.prim2 <- prim.box(x=qf, y=qf.label, threshold=c(0.5, -0.2),
  threshold.type=0, y.fun=median)
summary(qf.prim2)
#>            box-fun box-mass threshold.type
#> box1     0.8504155    0.144              1
#> box2    -0.2216066    0.233             -1
#> box3*    0.1634349    0.623             NA
#> overall  0.1726454    1.000             NA
#> 
predict(qf.prim2, newdata=c(0.6,0.2))
#> [1] 3