# 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
Run the code above in your browser using DataLab