# NOT RUN {
# 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[,6] - bmiData[,4])/bmiData[,4]
# Define the propensity for treatment model and methods.
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')
# Create modelObj object for contrast component
moCont <- buildModelObj(model = ~ parentBMI + month4BMI,
solver.method = 'lm')
# treatment regime rules at each decision point.
regimes <- function(a,b,c,data){
tst <- a + b*data$parentBMI + c*data$month4BMI > 0
res <- character(nrow(data))
res[tst] <- "MR"
res[!tst] <- "CD"
return(res)
}
# genoud requires some additional information
c1 <- c(-1,-1,-1)
c2 <- c( 1, 1, 1)
Domains <- cbind(c1,c2)
starts <- c(0,0,0)
#!! A LARGER VALUE FOR POP.SIZE IS RECOMMENDED
#!! THIS VALUE WAS CHOSEN TO MINIMIZE RUN TIME OF EXAMPLES
pop.size <- 50
# }
# NOT RUN {
ft <- optimalSeq(moPropen = moPropen, moMain = moMain, moCont = moCont,
data = bmiData, response = bmiData$y, txName = "A2",
regimes = regimes, iter = 0L,
pop.size = pop.size, starting.values = starts,
Domains = Domains, solution.tolerance = 0.0001)
## Available methods
# Coefficients of the propensity score and outcome regression
coef(ft)
# Description of method used to obtain object
DTRstep(ft)
# Estimated value of estimated optimal treatment for training data
estimator(ft)
# Value object returned by outcome regression method
fitObject(ft)
# Value object returned by genetic algorithm
genetic(ft)
# Estimated optimal treatment for training data
optTx(ft)
# Estimated optimal treatment for new data
optTx(ft, newdata = bmiData)
# Value object returned by outcome regression method
outcome(ft)
# Plots if defined by outcome regression method
dev.new()
par(mfrow = c(2,4))
plot(ft)
dev.new()
par(mfrow = c(2,4))
plot(ft, suppress = TRUE)
# Value object returned by propensity score regression method
propen(ft)
# Estimated decision function parameters
regimeCoef(ft)
# Show main results of method
show(ft)
# Show summary results of method
summary(ft)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab