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