Learn R Programming

iqLearn (version 1.5)

learnIQ1var: IQ-learning: contrast variance modeling

Description

Estimates the variance function of the contrast function by fitting a constant variance function or a log linear model to the residuals of the contrast mean fit.

Usage

learnIQ1var(object, ...)

# S3 method for formula learnIQ1var(formula, data, treatName, intNames, method, cmObject, ...) # S3 method for default learnIQ1var(object, H1CVar, s1sInts, method, ...)

Arguments

formula

right-hand side formula containing the linear model to be used for the log-transformed, squared residuals from the contrast function mean fit

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 variance model

method

either "homo" for a constant variance function or "hetero" for a log-linear variance function; default method is "homo"

cmObject

object of type learnIQ1cm

object

object of type learnIQ1cm

H1CVar

matrix or data frame of first-stage covariates to include as main effects in the log-linear model; default is NULL for a constant variance fit

s1sInts

indices pointing to columns of H1CVar that should be included as treatment interaction effects in the log-linear model; default is NULL

additional arguments to be passed to lm() when fitting the hetero log-linear model

Value

stdDev

standard deviation of the residuals from the contrast function mean fit when method="homo", otherwise NULL

stdResids

standardized residuals of the contrast function after mean and variance modeling, using either method="homo" or "hetero"

gammaHat0

estiamted regression coefficients from the log-linear model main effects when method="hetero", otherwise NULL

gammaHat1

estimated regression coefficients from the log-linear model interaction effects when method="hetero", otherwise NULL

s1VarFit

lm() object from the log-linear model when method="hetero", otherwise NULL

homo

logical variable indicating if method="homo" was used

sigPos

vector of predicted values when \(A1\)=1 for all patients

sigNeg

vector of predicted values when \(A1\)=-1 for all patients

s1sInts

indices of variables in H1CVar included as treatment interactions in the model; same as input s1sInts

Details

If method="homo", computes the variance of the residuals from the contrast function mean fit. If method="hetero", fits a model of the form $$E (\log e^2 | H_1, A_1) = H_{10}^{T}\gamma_0 + A_{1}H_{11}^{T} \gamma_1,$$ 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 contrast mean fit. Also, \(e^2\) = \(H21^T\)\(\beta21\) - \(E(H21^T \beta21 | H1, A1)\). For an object of type learnIQ1var, summary(object) and plot(object) can be used for evaluating model fit.

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.

See Also

learnIQ1cm, iqResids

Examples

Run this code
# 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]
## second-stage regression
fitIQ2 = learnIQ2 (y ~ gender + parent_BMI + month4_BMI +
  A2*(parent_BMI + month4_BMI), data=bmiData, "A2", c("parent_BMI",
                                  "month4_BMI"))
## model conditional expected value of main effect term
fitIQ1main = learnIQ1main (~ gender + race + parent_BMI + baseline_BMI
  + A1*(gender + parent_BMI), data=bmiData, "A1", c ("gender",
                                "parent_BMI"), fitIQ2)
## model conditional mean of contrast function
fitIQ1cm = learnIQ1cm (~ gender + race + parent_BMI + baseline_BMI +
  A1*(gender + parent_BMI + baseline_BMI), data=bmiData, "A1", c
  ("gender", "parent_BMI", "baseline_BMI"), fitIQ2)
## variance modeling
fitIQ1var = learnIQ1var (fitIQ1cm) ## constant variance fit 
fitIQ1var = learnIQ1var (fitIQ1cm, s1vars, c (3, 4), method="hetero")
## non-constant variance fit
fitIQ1var = learnIQ1var (~ gender + race + parent_BMI + baseline_BMI +
	  A1*(parent_BMI), data=bmiData, "A1", c ("parent_BMI"),
	  "hetero", fitIQ1cm) 
## non-constant variance fit using formula specification  
# }

Run the code above in your browser using DataLab