itrFit: Fitting Individualized Treatment Recommendation (ITR)

Description Usage Arguments Details Value Author(s) Examples

View source: R/itrFit.R

Description

Fit alternative individualized treatment recommendation (A-ITR) or ITR given a loss function and a kernel.

Usage

1
itrFit(x, a, y, p = 1/k, c = 1.2, method = "svm", kernel = "linear", epsilon = 1/2/median(d)^2, d = 2, lambda = 5^(-5:5), cv = FALSE, tunning = TRUE)

Arguments

x

a data frame or a matrix.

a

a factor or an integer vector indicating the treatment assigned to patients.

y

a numeric vector indicating the outcome after taking the treatment.

p

a numeric vector with each element between 0 to 1, indicating the probability of the treatment been assigned to the patient.

c

a numeric value no less than 1, indicating the bent slope of the loss.

method

the method to be used. Must be one of "svm", "dwd", "exp", "log" and "sq".

kernel

kernel type to be used. Currently only linear, gaussian, and polynomial are supported.

epsilon

a positive numeric value used only when kernel = "gaussian".

d

a positive integer used only when kernel = "polynomial".

lambda

a numeric vector indicating the penalty for tunning.

cv

logical. If TRUE then a 5-fold cross validation is performed.

tunning

logical. If TRUE then a tunning procedure for delta and fence (used for predicting A-ITR) is performed.

Details

This function fits an individualized treatment recommendation under a bent loss. The bent slope is controled by the parameter c. When c = 1, it degenerates to the traditional ITR fit. For the purpose of saving computation time, it is suggested to set cv = TRUE for bent svm loss and cv = FALSE for other bent losses. It is also suggested to set tunning = TRUE for fitting A-ITR.

Value

itrFit returns an object of class c("itrfit.svm", "itrfit") or c("itrfit.dif", "itrfit"). An object of class "itrfit" is a list containing at least the following components:

obj_value

the expected outcome under the traditional ITR. If tunning = TRUE, the weighted expected outcome (for evaluating an A-ITR) is also returned.

optlambda

the optimal lambda.

c

the bent slope.

level

the treatment levels.

x

the input covariate x used for fitting.

a

the input treatment a used for fitting.

y

the input outcome y used for fitting.

method

the method used.

kernel

the kernel matrix computed.

predict

an object of class "ITR". If tunning = TRUE, return A-ITR, otherwise return ITR.

refine_par

if tunning = TRUE, the tunning parameter used for predicting the A-ITR.

In addition, the fitted coefficients are returned depending on the object class. Specifically, theta_s_gamma for "itrfit.svm" object, and coef for "itrfit.dif" object.

Author(s)

Haomiao Meng

Examples

1
2
3
4
5
6
data(sim1)
data = sim1[1:1000, ]

res = itrFit(data[, 1:2], data[, 3], data[, 4], cv = TRUE) #using bent svm loss
res = itrFit(data[, 1:2], data[, 3], data[, 4], kernel = 'polynomial', d = 4, lambda = 5^(4:11)) #using bent svm loss with polynomial kernel
res = itrFit(data[, 1:2], data[, 3], data[, 4], method = 'square', kernel = 'polynomial', d = 2, lambda = 5^(0:6)) #using bent square loss

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