Learn R Programming

DynTxRegime (version 3.01)

.newRWL: Residual Weighted Learning.

Description

Estimates the optimal treatment regime using residual weighted learning.

Usage

.newRWL(moPropen, moMain, ...)
# S4 method for modelObj,modelObj
.newRWL(moPropen, moMain, data, response, txName, regime, lambdas, cvFolds, 
        kernel, kparam, responseType, txVec, guess, suppress)

Arguments

moPropen
"modelObj" for propensity score regression.
moMain
"modelObj" for outcome regression.
...
Used to pass arguments that are required but the class of which does not determine the method that is selected.
data
"data.frame" of covariates and treatment history.
response
Outcome of interest.
txName
Treatment variable column header in data.
regime
"formula" description of decision function.
lambdas
Tuning parameter(s).
cvFolds
Number of cross-validation folds.
kernel
"character" description of kernel function.
kparam
"numeric" parameter for kernel function.
responseType
"character" indicating if outcome is continuous or count data.
txVec
Treatment vector recast as +/- 1.
guess
Inital parameter guesses for optimization routine.
suppress
T/F indicating if prints to screen are executed.

Examples

Run this code

data(bmiData)

y <- -(bmiData$month12BMI - bmiData$month4BMI) / bmiData$month4BMI * 100

moPropen <- buildModelObj(model = ~1, 
                          solver.method = 'glm',
                          solver.args = list("family" = "binomial"),
                          predict.args = list("type" = "response"))

moMain <- buildModelObj(model = ~ parentBMI + baselineBMI + month4BMI, 
                        solver.method = 'lm')

regime <- ~ parentBMI + baselineBMI + gender

txVec <- numeric(nrow(bmiData)) - 1L
txVec[bmiData$A2 == "MR"] <- 1L
bmiData$A2 <- as.factor(bmiData$A2)
## Not run: ------------------------------------
# obj <- DynTxRegime:::.newRWL(moPropen = moPropen,
#                              moMain = moMain,
#                              data = bmiData,
#                              response = y,
#                              txName = "A2",
#                              regime = regime,
#                              lambdas = 0.1,
#                              cvFolds = 0L,
#                              kernel = "linear",
#                              kparam = NULL,
#                              responseType = "continuous",
#                              txVec = txVec,
#                              guess = NULL,
#                              suppress = TRUE)
# 
# is(obj)
# coef(obj)
# cvInfo(obj)
# DTRstep(obj)
# estimator(obj)
# fitObject(obj)
# optimObj(obj)
# optTx(obj)
# optTx(obj,bmiData)
# outcome(obj)
# print(obj)
# propen(obj)
# regimeCoef(obj)
# show(obj)
# summary(obj)
# 
# obj <- DynTxRegime:::.newRWL(moPropen = moPropen,
#                              moMain = moMain,
#                              data = bmiData,
#                              response = y,
#                              txName = "A2",
#                              regime = regime,
#                              lambdas = c(0.1,0.2),
#                              cvFolds = 4L,
#                              kernel = "linear",
#                              kparam = NULL,
#                              responseType = "continuous",
#                              txVec = txVec,
#                              guess = NULL,
#                              suppress = TRUE)
# 
# is(obj)
# coef(obj)
# cvInfo(obj)
# DTRstep(obj)
# estimator(obj)
# fitObject(obj)
# optimObj(obj)
# optTx(obj)
# optTx(obj,bmiData)
# outcome(obj)
# print(obj)
# propen(obj)
# regimeCoef(obj)
# show(obj)
# summary(obj)
# 
# 
# obj <- DynTxRegime:::.newRWL(moPropen = moPropen,
#                              moMain = moMain,
#                              data = bmiData,
#                              response = y,
#                              txName = "A2",
#                              regime = regime,
#                              lambdas = c(0.1,0.2),
#                              cvFolds = 4L,
#                              kernel = "radial",
#                              kparam = c(1,2),
#                              responseType = "continuous",
#                              txVec = txVec,
#                              guess = NULL,
#                              suppress = TRUE)
# 
# is(obj)
# coef(obj)
# cvInfo(obj)
# DTRstep(obj)
# estimator(obj)
# fitObject(obj)
# optimObj(obj)
# optTx(obj)
# optTx(obj,bmiData)
# outcome(obj)
# print(obj)
# propen(obj)
# regimeCoef(obj)
# show(obj)
# summary(obj)
# 
# obj <- DynTxRegime:::.newRWL(moPropen = moPropen,
#                              moMain = moMain,
#                              data = bmiData,
#                              response = y,
#                              txName = "A2",
#                              regime = regime,
#                              lambdas = 0.1,
#                              cvFolds = 4L,
#                              kernel = "radial",
#                              kparam = c(1,2),
#                              responseType = "continuous",
#                              txVec = txVec,
#                              guess = NULL,
#                              suppress = TRUE)
# 
# is(obj)
# coef(obj)
# cvInfo(obj)
# DTRstep(obj)
# estimator(obj)
# fitObject(obj)
# optimObj(obj)
# optTx(obj)
# optTx(obj,bmiData)
# outcome(obj)
# print(obj)
# propen(obj)
# regimeCoef(obj)
# show(obj)
# summary(obj)
## ---------------------------------------------

Run the code above in your browser using DataLab