# learnIQ1cm: IQ-learning: contrast function mean regression In iqLearn: Interactive Q-Learning

## Description

Estimates the mean of the contrast function by fitting a linear regression of the estimated contrast function term on first-stage history and treatment.

## Usage

 ```1 2 3 4 5 6``` ```learnIQ1cm(object, ...) ## S3 method for class 'formula' learnIQ1cm(formula, data, treatName, intNames, s2object, ...) ## Default S3 method: learnIQ1cm(object, H1CMean, A1, s1cmInts, ...) ```

## Arguments

 `formula ` formula for the contrast function mean regression `data ` data frame containing variables used in `formula` `treatName ` character string indicating the stage 1 treatment name `intNames ` vector of characters indicating the names of the variables that interact with the stage 1 treatment in the contrast function mean regression model `s2object ` object of type `learnIQ2` `object ` object of type `learnIQ2` `H1CMean ` matrix or data frame of first-stage covariates to include as main effects in the linear model `A1 ` vector of first-stage randomized treatments `s1cmInts ` indices pointing to columns of H1CMean that should be included as treatment interaction effects in the linear model `... ` other arguments to be passed to `lm()`

## Details

Fits a model of the form

E (H21^Tβ21 | H1, A1) = H11^Tβ10 + A1*H11^Tβ11,

where H10 and H11 are summaries of H1. Though a slight abuse of notation, these summaries are not required to be the same as H10 and H11 in the main effect term regression or the variance model. For an object of type `learnIQ1cm`, `summary(object)` and `plot(object)` can be used for evaluating model fit.

## Value

 `betaHat10 ` estimated main effect coefficients; first is the intercept `betaHat11 ` estimated treatment interaction coefficients; first is the main effect of the first-stage treatment `s1cmFit ` `lm()` object of the contrast mean regression fit `cmeanResids ` residuals from the regression `cmPos ` vector of predicted values with A1=1 for all patients `cmNeg ` vector of predicted values with A1=1 for all patients `s1cmInts ` indicies of variables in H1CMean included as treatment interactions in the model; same as input `s1cmInts` `A1 ` vector of first-stage randomized treatments; same as input `A1`

## Author(s)

Kristin A. Linn <[email protected]>, Eric B. Laber, Leonard A. Stefanski

## References

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.

`learnIQ2`, `summary.learnIQ1cm`, `plot.learnIQ1cm`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25``` ```## 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 (y ~ gender + parent_BMI + month4_BMI + A2*(parent_BMI + month4_BMI), data=bmiData, "A2", c("parent_BMI", "month4_BMI")) fitIQ1cm = learnIQ1cm (~ gender + race + parent_BMI + baseline_BMI + A1*(gender + parent_BMI + baseline_BMI), data=bmiData, "A1", c ("gender", "parent_BMI", "baseline_BMI"), fitIQ2) summary (fitIQ1cm) plot (fitIQ1cm) ```