Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

qLearn

A Step of the Q-Learning Algorithm


Description

Performs a single step of the Q-Learning algorithm. If an object of class QLearn is passed through input response, it is assumed that the QLearn object is the value object returned from the preceding step of the Q-Learning algorithm, and the value fit by the regression is taken from the QLearn object. If a vector is passed through input response, it is assumed that the call if for the first step in the Q-Learning algorithm, and models are fit using the provided response.

Usage

qLearn(
  ...,
  moMain,
  moCont,
  data,
  response,
  txName,
  fSet = NULL,
  iter = 0L,
  verbose = TRUE
)

Arguments

...

ignored. Provided to require named inputs.

moMain

An object of class modelObj or a list of objects of class modelObjSubset, which define the models and R methods to be used to obtain parameter estimates and predictions for the main effects component of the outcome regression.
See ?modelObj and/or ?modelObjSubset for details.
NULL is an acceptable value if moCont is defined.

moCont

An object of class modelObj or a list of objects of class modelObjSubset, which define the models and R methods to be used to obtain parameter estimates and predictions for the contrasts component of the outcome regression.
See ?modelObj and/or ?modelObjSubset for details.
NULL is an acceptable value if moMain is defined.

data

A data frame of covariates and treatment history.

response

A response vector or object of class QLearn from a previous Q-Learning step.

txName

A character string giving column header of treatment variable in data

fSet

NULL or a function. This argument allows the user to specify the subset of treatment options available to a patient. See ?fSet for details of allowed structure

iter

An integer. See ?iter for details

verbose

A logical. If TRUE, screen prints are generated.

Value

An object of class QLearn-class

See Also

Other statistical methods: bowl(), earl(), iqLearn, optimalClass(), optimalSeq(), owl(), rwl()

Other multiple decision point methods: bowl(), iqLearn, optimalClass(), optimalSeq()

Other single decision point methods: earl(), optimalClass(), optimalSeq(), owl(), rwl()

Examples

# Load and process data set
data(bmiData)

# define the negative 12 month change in BMI from baseline
y12 <- -100*(bmiData[,6L] - bmiData[,4L])/bmiData[,4L]

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

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

#### Second-Stage Analysis
fitSS <- qLearn(moMain = moMain, moCont = moCont,
                data = bmiData, response = y12,  txName = 'A2')

##Available methods

  # Coefficients of the outcome regression objects
  coef(fitSS)

  # Description of method used to obtain object
  DTRstep(fitSS)

  # Estimated value of the optimal treatment regime for training set
  estimator(fitSS)

  # Value object returned by outcome regression method
  fitObject(fitSS)

  # Estimated optimal treatment and decision functions for training data
  optTx(fitSS)

  # Estimated optimal treatment and decision functions for new data
  optTx(fitSS, bmiData)

  # Value object returned by outcome regression method
  outcome(fitSS)

  # Plots if defined by outcome regression method
  dev.new()
  par(mfrow = c(2,4))

  plot(fitSS)
  plot(fitSS, suppress = TRUE)

  # Show main results of method
  show(fitSS)

  # Show summary results of method
  summary(fitSS)
 
#### First-stage Analysis

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

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

fitFS <- qLearn(moMain = moMain, moCont = moCont,
                data = bmiData, response = fitSS,  txName = 'A1')

##Available methods for fitFS are as shown above for fitSS

DynTxRegime

Methods for Estimating Optimal Dynamic Treatment Regimes

v4.10
GPL-2
Authors
S. T. Holloway, E. B. Laber, K. A. Linn, B. Zhang, M. Davidian, and A. A. Tsiatis
Initial release
2022-06-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.