Learn R Programming

DynTxRegime (version 3.01)

rwl:

Description

Estimation of an optimal dynamic treatment regime using residual weighted learning (RWL). The method is limited to single-decision-point scenarios with binary treatment options.

Usage

rwl(..., moPropen, moMain, data, reward, txName, regime,
    lambdas = 2.0, cvFolds = 0L, kernel = "linear",
    kparam = NULL, responseType = "continuous", 
    guess = NULL, verbose = TRUE)

Arguments

ignored. Included to require named input.
moPropen
An object of class "modelObj." This object specifies the model of the propensity for treatment regression and the R methods to be used to obtain parameter estimates and predictions. The method specified to obtain predictions must return the prediction on the scale of the probability, i.e., returned values must be in the interval (0,1). See moPropen for further information.
moMain
A single object of class "modelObj." This object specifies the model of the main effects component of the outcome regression and the R methods to be used to obtain parameter estimates and predictions. The method chosen to obtain predictions must return the prediction on the scale of the response variable.
data
An object of class "data.frame." The covariates and treatment histories.
reward
An object of class "vector." A vector of the outcome of interest.
txName
An object of class "character." The column header of the stage treatment variable as given in input data. Treatment must be binary and will be recoded as -1/+1 if not provided as such.
regime
An object of class "formula." The formula defines the decision rule, i.e., the covariates to be included in the kernel.
lambdas
An object of class "numeric." Tuning parameter to avoid overfitting. If more than one is given and cvFolds > 0, cross-validation will be used to select an optimal from among those provided.
cvFolds
An object of class "integer." If cross-validation is to be used to find an optimal lambda and/or kernel parameter, the number of folds to use in the CV.
kernel
An object of class "character." In conjunction with input kparam, this input specifies the kernel function to be used. Must be one of {'linear', 'poly', or 'radial'}. If 'linear,' the linear kernel; kparam is ignored. If 'poly,' the polynomial kernel; kparam must be specified. If 'radial,' the Gaussian radial basis function kernel; kparam must be specified.
kparam
An object of class "numeric." If input kernel = 'linear', this input is ignored. If input kernel = 'poly', this input is the order of the polynomial. If input kernel = 'radial', this input is sigma; i.e., $$K(x,y) = exp(||x-y||^2 / (2*sigma^2)).$$ For kernel = 'radial', a vector of kernel parameters can be provided, and cross-validation will be used to determine the optimal of those provided. Note that input cvFolds must be > 0.
responseType
An object of class "character." One of continuous, binary, count indicating the type of response variable.
guess
An object of class "numeric" or NULL. Starting parameter values for optimization method.
verbose
An object of class "logical." If FALSE, screen prints will be suppressed.

Value

Returns an object of class "RWL" that inherits directly from class "DynTxRegime."

Methods

coef
signature(object = "RWL"): Retrieve parameter estimates for all regression steps.

cvInfo
signature(object = "RWL"): Retrieve cross-validation results.

DTRstep
signature(object = "RWL"): Retrieve description of method used to create object.

estimator
signature(x = "RWL"): Retrieve the estimated value of the estimated optimal regime for the training data set.

fitObject
signature(object = "RWL"): Retrieve value object returned by regression methods.

optimObj
signature(object = "RWL"): Retrieve value object returned by optimization routine.

optTx
signature(x = "RWL", newdata = "missing"): Retrieve the estimated optimal treatment regime for training data set.

optTx
signature(x = "RWL", newdata = "data.frame"): Estimate the optimal treatment regime for newdata.

outcome
signature(x = "RWL"): Retrieve value object returned by outcome regression methods.

plot
signature(x = "RWL"): Generate plots for regression analyses.

print
signature(object = "RWL"): Print main results of analysis.

propen
signature(x = "RWL"): Retrieve value object returned by propensity score regression methods.

regimeCoef
signature(object = "RWL"): Retrieve the estimated decision function parameter estimates.

residuals
signature(object = "RWL"): Retrieve residuals of outcome regression.

show
signature(object = "RWL"): Show main results of analysis.

summary
signature(object = "RWL"): Retrieve summary information from regression analyses.

References

Zhou, X., Mayer-Hamblett, N., Kham, U., and Kosorok, M. R. (2016+). Residual Weighted Learning for Estimating Individualized Treatment Rules. Journal of the American Statistical Association, in press.

Examples

Run this code
# Load and process data set
  data(bmiData)

  # define response y to be the negative 12 month
  # change in BMI from baseline
  bmiData$y <- -100*(bmiData$month12BMI - bmiData$baselineBMI) /
                     bmiData$baselineBMI


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

# Create modelObj object for main effect component
  moMain <- buildModelObj(model = ~ gender + parentBMI + month4BMI,
                          solver.method = 'lm')
  ## Not run: ------------------------------------
#     rwlRes <- rwl(moPropen = moPropen, moMain = moMain,
#                   data = bmiData, reward = bmiData$y, txName = "A2", 
#                   regime = ~ parentBMI + month4BMI)
# 
# ##Available methods
# 
#   # Coefficients of the propensity score regression
#   coef(rwlRes)
# 
#   # Description of method used to obtain object
#   DTRstep(rwlRes)
# 
#   # Estimated value of the optimal treatment regime for training set
#   estimator(rwlRes)
# 
#   # Value object returned by propensity score regression method
#   fitObject(rwlRes)
# 
#   # Summary of optimization routine
#   optimObj(rwlRes)
# 
#   # Estimated optimal treatment for training data
#   optTx(rwlRes)
# 
#   # Estimated optimal treatment for new data
#   optTx(rwlRes, bmiData)
# 
#   # Value object returned by outcome regression method
#   outcome(rwlRes)
# 
#   # Plots if defined by propensity regression method
#   dev.new()
#   par(mfrow = c(2,4))
#   plot(rwlRes)
# 
#   dev.new()
#   par(mfrow = c(2,4))
#   plot(rwlRes, suppress = TRUE)
# 
#   # Value object returned by propensity score regression method
#   propen(rwlRes)
# 
#   # Parameter estimates for decision function
#   regimeCoef(rwlRes)
# 
#   # Residuals used on method
#   residuals(rwlRes)
# 
#   # Show main results of method
#   show(rwlRes)
# 
#   # Show summary results of method
#   summary(rwlRes)
#  
#   
## ---------------------------------------------

Run the code above in your browser using DataLab