Description Usage Arguments Value Examples
Function that runs fully nested SuperLearner cross validated estimates on V-folds. Only supports binary treatment.
1 2 |
Y, |
outcome vector |
X, |
data.frame of variables that Y is a function of. |
A, |
treatment vector |
W, |
vector of variables A is a function of. |
newdata, |
dataframe of X, stacked with X when A=1 and X when A=0, in that order |
method, |
the SuperLearner meta learning method |
SL.library, |
SuperLearner Library for finding outcome model |
SL.libraryG, |
SuperLearner Library for the treatment mechanism |
V, |
the number of folds |
mc.cores, |
number of cores to use for parallel processing the SuperLearner. Note, this parallelizes across the folds not within SuperLearner |
A list with 5 elements: initdata: the initdata argument for running tmle with gentmle function
Qcoef: the avg SuperLearner coef for each model in the outcome regression
Gcoef: the avg SuperLearner coef for each model in the treatment mech regression
Qrisk: the avg SuperLearner risk for each model in the outcome regression
Grisk: the avg SuperLearner risk for each model in the treatment mech
inds: the indices for all the val sets, stacked to match
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 26 27 28 29 30 31 32 33 34 | # basic example with very simple SuperLearner library
# generate the data according to a couple of built-in functions here
data = gendata(1000, g0 = g0_linear, Q0 = Q0_trig1)
#drop Y
Y = data$Y
A = data$A
#drop Y to form X and form newdata
X = data[,-6]
X0 = X1 = X
X0$A = 0
X1$A = 1
newdata = rbind(X,X1,X0)
#form W
W = X[,-1]
#declare SL library
SL.library = SL.libraryG = c("SL.glm","SL.mean")
stack = SL.stack(Y, X, A, W, newdata, method = "method.NNloglik",
SL.library, SL.libraryG, V=10, mc.cores = 4)
# simultaneously run one-step tmle for ATE and blip variance with
# simultaneous CI
tmle.info = gentmle(initdata=stack$initdata,
params=list(param_ATE,param_sigmaATE),
submodel = submodel_logit, loss = loss_loglik,
approach = "recursive", max_iter = 10000,
g.trunc = 1e-2,
simultaneous.inference = TRUE)
tmle.info$steps
# get simultaneous CIs
ci_gentmle(tmle.info)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.