Learn R Programming

DynTxRegime (version 3.01)

.newBOWLBasic: Backward Outcome Weighted Learning With Binary Treatment.

Description

Estimates the optimal treatment using outcome weighted learning for a single decision point and binary treatments. Method is not exported.

Usage

.newBOWLBasic(regime, txInfo, ...)
# S4 method for formula,txInfoNoSubsets
.newBOWLBasic(regime, txInfo, ind, prWgt, response, txVec, data, kernel, kparam, 
              lambdas, cvFolds, suppress)
# S4 method for formula,txInfoWithSubsets
.newBOWLBasic(regime, txInfo, ind, prWgt, response, txVec, data, kernel, kparam, 
              lambdas, cvFolds, suppress)

Arguments

regime
"formula" description of decision rule.
txInfo
"TxInfoNoSubsets" object.
...
Used to pass arguments that are required but the class of which does not determine the method that is selected.
ind
T/F indicating if optimal treatment has been followed beyond this decision point.
prWgt
Product of probabilities for received treatment beyond this decision point.
response
Sum of rewards including this decision point.
txVec
Recast treatment vector as +/-1.
data
"data.frame" of covariates and treatment histories.
kernel
"character" description of kernel function.
kparam
"numeric" parameter for kernel function.
lambdas
Tuning parameter(s).
cvFolds
Number of cross-validation folds.
suppress
T/F indicating if print to screens should be executed

Examples

Run this code

data(bmiData)

y <- -(bmiData$month12BMI - bmiData$month4BMI) / bmiData$month4BMI * 100
miny <- min(y)
if(miny < 0.0) y <- y - miny

prWgt <- numeric(nrow(bmiData)) + 0.5

regime <- ~ parentBMI + baselineBMI + gender

txVec <- numeric(nrow(bmiData)) - 1L
txVec[bmiData$A2 == "MR"] <- 1L
bmiData$A2 <- as.factor(bmiData$A2)

txInfo <- DynTxRegime:::.newTxInfo(fSet = NULL, txName = "A2", data = bmiData, 
                                   suppress = TRUE, verify = TRUE)

obj <- DynTxRegime:::.newBOWLBasic(regime = regime,
                                   txInfo = txInfo,
                                   ind = !logical(nrow(bmiData)),
                                   prWgt = prWgt,
                                   response = y,
                                   txVec = txVec,
                                   data = bmiData,
                                   kernel = "linear",
                                   kparam = NULL,
                                   lambdas = 0.1,
                                   cvFolds = 0L,
                                   suppress = TRUE)

is(obj)
cvInfo(obj)
optimObj(obj)
DynTxRegime:::.predictOptimalTx(obj)
DynTxRegime:::.predictOptimalTx(obj,bmiData)
print(obj)
regimeCoef(obj)
show(obj)
summary(obj)


obj <- DynTxRegime:::.newBOWLBasic(regime = regime,
                                   txInfo = txInfo,
                                   ind = !logical(nrow(bmiData)),
                                   prWgt = prWgt,
                                   response = y,
                                   txVec = txVec,
                                   data = bmiData,
                                   kernel = "linear",
                                   kparam = NULL,
                                   lambdas = c(0.1,0.2,0.3),
                                   cvFolds = 4L,
                                   suppress = TRUE)

is(obj)
cvInfo(obj)
optimObj(obj)
DynTxRegime:::.predictOptimalTx(obj)
DynTxRegime:::.predictOptimalTx(obj,bmiData)
print(obj)
regimeCoef(obj)
show(obj)
summary(obj)

fSet <- function(data){
          subsets = list(list("subset1", c("CD","MR")),
                         list("subset2", c("CD")))
          txOpts <- character(nrow(data))
          txOpts[data$A1 == "CD"] <- "subset1"
          txOpts[data$A1 == "MR"] <- "subset2"

          return(list("subsets" = subsets, "txOpts" = txOpts))
        }

df <- bmiData
df$A2[df$A1 == "MR"] <- "CD"

txInfo <- DynTxRegime:::.newTxInfo(fSet = fSet, txName = "A2", data = df, 
                                   suppress = TRUE, verify = TRUE)

obj <- DynTxRegime:::.newBOWLBasic(regime = regime,
                                    txInfo = txInfo,
                                    ind = !logical(nrow(df)),
                                    prWgt = prWgt,
                                    response = y,
                                    txVec = txVec,
                                    data = df,
                                    kernel = "linear",
                                    kparam = NULL,
                                    lambdas = 0.1,
                                    cvFolds = 0L,
                                    suppress = TRUE)

is(obj)
cvInfo(obj)
optimObj(obj)
DynTxRegime:::.predictOptimalTx(obj)
DynTxRegime:::.predictOptimalTx(obj,df)
print(obj)
regimeCoef(obj)
show(obj)
summary(obj)


obj <- DynTxRegime:::.newBOWLBasic(regime = regime,
                                   txInfo = txInfo,
                                   ind = !logical(nrow(df)),
                                   prWgt = prWgt,
                                   response = y,
                                   txVec = txVec,
                                   data = df,
                                   kernel = "linear",
                                   kparam = NULL,
                                   lambdas = c(0.1,0.2,0.3),
                                   cvFolds = 4L,
                                   suppress = TRUE)

is(obj)
cvInfo(obj)
optimObj(obj)
DynTxRegime:::.predictOptimalTx(obj)
DynTxRegime:::.predictOptimalTx(obj,bmiData)
print(obj)
regimeCoef(obj)
show(obj)
summary(obj)

Run the code above in your browser using DataLab