if (FALSE) { 
# 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]
# propensity model
moPropen <- buildModelObj(model = ~parentBMI+month4BMI,
                          solver.method = 'glm',
                          solver.args = list('family'='binomial'),
                          predict.method = 'predict.glm',
                          predict.args = list(type='response'))
# outcome model
moMain <- buildModelObj(model = ~parentBMI+month4BMI,
                        solver.method = 'lm')
fitRWL <- rwl(moPropen = moPropen, moMain = moMain,
              data = bmiData, reward = y12,  txName = 'A2', 
              regime = ~ parentBMI + month4BMI,
              kernel = 'radial', kparam = 1.5)
##Available methods
  # Coefficients of the regression objects
  coef(fitRWL)
  # Description of method used to obtain object
  DTRstep(fitRWL)
  # Estimated value of the optimal treatment regime for training set
  estimator(fitRWL)
  # Value object returned by regression methods
  fitObject(fitRWL)
  # Summary of optimization routine
  optimObj(fitRWL)
  # Estimated optimal treatment for training data
  optTx(fitRWL)
  # Estimated optimal treatment for new data
  optTx(fitRWL, bmiData)
  # Value object returned by outcome regression method
  outcome(fitRWL)
  # Plots if defined by regression methods
  dev.new()
  par(mfrow = c(2,4))
  plot(fitRWL)
  plot(fitRWL, suppress = TRUE)
  # Value object returned by propensity score regression method
  propen(fitRWL)
  # Parameter estimates for decision function
  regimeCoef(fitRWL)
  # Show main results of method
  show(fitRWL)
  # Show summary results of method
  summary(fitRWL)
 }
Run the code above in your browser using DataLab