Learn R Programming

DynTxRegime (version 3.2)

.newIterateFit: Complete Outcome Regression Step When Two Component Model.

Description

Complete an outcome regression step when iterative method is required and subsets are not used for modeling. Method is not exported.

Usage

.newIterateFit(moMain, moCont, txInfo, ...)

# S4 method for modelObj,modelObj,TxInfoNoSubsets .newIterateFit(moMain, moCont, txInfo, response, data, max.iter, suppress) # S4 method for modelObj,modelObj,TxInfoWithSubsets .newIterateFit(moMain, moCont, txInfo, response, data, max.iter, suppress)

Arguments

moMain

"modelObj" for main effects component of model.

moCont

"modelObj" for contrasts component of model.

txInfo

Treatment information.

...

Used to pass arguments that are required but the class of which does not determine the method that is selected.

response

Vector of outcome of interest.

data

"data.frame" of covariates and treatment histories.

max.iter

Maximum number of iterations.

suppress

T/F indicating if screen prints are generated.

Examples

Run this code
# NOT RUN {
data(bmiData)

bmiData$A2 <- as.factor(bmiData$A2)

moMain <- buildModelObj(model = ~month4BMI + baselineBMI, 
                        solver.method = 'lm')
moCont <- buildModelObj(model = ~month4BMI + baselineBMI, 
                        solver.method = 'lm')

y <- -(bmiData$month12BMI - bmiData$month4BMI) / bmiData$month4BMI * 100

# Treatment Object
txInfo <- DynTxRegime:::.newTxInfo(fSet = NULL, 
                                   txName = "A1", 
                                   data = bmiData, 
                                   suppress = TRUE, 
                                   verify = TRUE)

obj <- DynTxRegime:::.newIterateFit(moMain = moMain, 
                                    moCont = moCont, 
                                    txInfo = txInfo, 
                                    data = bmiData, 
                                    response = y, 
                                    max.iter = 100L, 
                                    suppress = TRUE)

is(obj)
coef(obj)
fitObject(obj)
plot(obj)
predict(obj)
predict(obj, bmiData)
DynTxRegime:::.predictAllTreatments(object = obj, data = bmiData)
print(obj)
show(obj)
summary(obj)

fSet1 <- function(data){
           subsets <- list(list("subset1",c("CD","MR")),
                           list("subset2",c("MR")))
           txOpts <- character(nrow(data))
           txOpts[data$baselineBMI <= 35] <- "subset2"
           txOpts[data$baselineBMI > 35] <- "subset1"
           return(list("subsets" = subsets, "txOpts" = txOpts))
         }

txInfo <- DynTxRegime:::.newTxInfo(fSet = fSet1, 
                                   txName = "A2", 
                                   data = bmiData, 
                                   suppress = TRUE, 
                                   verify = TRUE)

obj <- DynTxRegime:::.newIterateFit(moMain = moMain, 
                                    moCont = moCont, 
                                    txInfo = txInfo, 
                                    data = bmiData, 
                                    response = y, 
                                    max.iter = 100L, 
                                    suppress = TRUE)

is(obj)
coef(obj)
fitObject(obj)
plot(obj)
predict(obj)
predict(obj, bmiData)
DynTxRegime:::.predictAllTreatments(object = obj, data = bmiData)
print(obj)
show(obj)
summary(obj)
# }

Run the code above in your browser using DataLab