Fits a linear regression of the response on second-stage history and treatment to estimate the optimal second-stage decision rule.
learnIQ2(H2, ...)# S3 method for formula
learnIQ2(formula, data, treatName, intNames, ...)
# S3 method for default
learnIQ2(H2, Y, A2, s2ints, ...)
stage 2 regression formula
data frame containing variables used in formula
character string indicating the stage 2 treatment name
vector of characters indicating the names of the variables that interact with the stage 2 treatment in the regression model
matrix or data frame of second-stage covariates to include as main effects in the linear model
response vector
vector of second-stage randomized treatments
indices pointing to columns of H2 that should be included as treatment interaction effects in the linear model
other arguments to be passed to lm()
estimated main effect coefficients; first is the intercept
estimated treatment interaction coefficients; first is the main effect of the second-stage treatment
lm()
object of the second-stage regression fit
vector of estimated optimal second-stage treatments for the patients in the training data
estimated main effect vector,
estimated contrast function vector,
indicies of variables in H2 included as treatment
interactions in the model; same as input s2ints
vector of second-stage randomized treatments; same as
input A2
Fits a model of the form
learnIQ2
,
summary(object)
and plot(object)
can be used for
evaluating model fit.
Linn, K. A., Laber, E. B., Stefanski, L. A. (2015) "iqLearn: Interactive Q-Learning in R", Journal of Statistical Software, 64(1), 1--25.
Laber, E. B., Linn, K. A., and Stefanski, L. A. (2014) "Interactive model building for Q-learning", Biometrika, 101(4), 831-847.
# NOT RUN {
## load in two-stage BMI data
data (bmiData)
bmiData$A1[which (bmiData$A1=="MR")] = 1
bmiData$A1[which (bmiData$A1=="CD")] = -1
bmiData$A2[which (bmiData$A2=="MR")] = 1
bmiData$A2[which (bmiData$A2=="CD")] = -1
bmiData$A1 = as.numeric (bmiData$A1)
bmiData$A2 = as.numeric (bmiData$A2)
s1vars = bmiData[,1:4]
s2vars = bmiData[,c (1, 3, 5)]
a1 = bmiData[,7]
a2 = bmiData[,8]
## define response y to be the negative 12 month change in BMI from
## baseline
y = -(bmiData[,6] - bmiData[,4])/bmiData[,4]
s2ints = c (2, 3)
## second-stage regression
fitIQ2 = learnIQ2 (s2vars, y, a2, s2ints)
fitIQ2 = learnIQ2 (y ~ gender + parent_BMI + month4_BMI +
A2*(parent_BMI + month4_BMI), data=bmiData, "A2", c("parent_BMI",
"month4_BMI"))
summary (fitIQ2)
plot (fitIQ2)
# }
Run the code above in your browser using DataLab