predict.itrfit: Predict Method for ITR Fit

Description Usage Arguments Details Value Author(s) Examples

View source: R/predict.itrfit.R

Description

Predict the options based on "itrfit" object.

Usage

1
2
## S3 method for class "itrfit"
predict(obj, newdata = NULL, option = "refine", delta = NULL, fence = NULL, c = obj$c)

Arguments

obj

object of class inheriting from "itrfit".

newdata

an optional data frame or a data matrix in which to look for variables with which to predict. If omitted, the fitted options are used.

option

the option used for prediction. option = "normal" will produce ITR while option = "refine" will produce A-ITR.

delta

a numeric value greater than -1 used for predicting A-ITR, can be omitted if option = "normal" or tunning = TRUE when itrFit is called.

fence

a numeric value greater than 0 used for predicting A-ITR, can be omitted if option = "normal" or tunning = TRUE when itrFit is called.

c

a numeric value no less than 1, ignored unless obj is of class "itrfit.dif" and obj$c = 1.

Details

There are two prediction methods for "itrfit" object when option = "refine". One is based on bent loss, where a one-step estimation is applied. Another is based on differentiable loss, which is a two-step estimation procedure. We recommand the first method in practice.

Value

predict.itrfit preduces a 0-1 matrix of class "ITR", where the column names are the treatment levels and ith row indicates which treatments are suggested to ith patient. Specifically, 1 stands for "suggested" and 0 stands for "not suggested".

Author(s)

Haomiao Meng

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(sim1)
train = sim1[1:1000, ]
test = sim1[3001:5000, ]

res = itrFit(train[, 1:2], train[, 3], train[, 4], kernel = "polynomial", d = 4, lambda = 5^(4:11)) #bent hinge loss fit
rule = predict(res, test[, 1:2], option = "normal") #prediction for ITR
plot(test[, 1], test[, 2], col = pred_to_num(rule) + 1)

rule = predict(res, test[, 1:2]) #prediction for A-ITR using the one-step estimation
plot(test[, 1], test[, 2], col = pred_to_num(rule) + 1)

res = itrFit(train[, 1:2], train[, 3], train[, 4], c = 1, method = "log", kernel = "polynomial", d = 2, lambda = 5^(0:8)) #common logistic loss (unbent) fit
rule = predict(res, test[, 1:2], c = 1.2) #prediction for A-ITR using the two-step estimation
plot(test[, 1], test[, 2], col = pred_to_num(rule) + 1)

menghaomiao/itrrnr documentation built on June 21, 2020, 2:22 a.m.