Description Usage Arguments Value Examples
computes delta method inferencec for logistic regression plug-in estimator of treatment specific mean for survival data in wide form, including pt treatment. Also does logistic regression plug-in using clever covariate in the regression, inference computed using delta method as well. Note, in performing tmle, pscores are obtained via user supplied regression formulas for each time point. Formulas for the conditional means are also user supplied.
1 2 |
data, |
data.frame of variables in time ordering from left to right |
Ynodes, |
character vector of time-ordered Ynodes |
Anodes, |
character vector of time-ordered Anodes |
formulas, |
list of formulas for the conditional means |
setA |
the value to which you intervene on A,vector of length that of Anodes |
alpha |
significance level for two-sided CI. |
formulas_g |
NULL by default but must be filled in if tmle = TRUE |
tmle |
option to put a clever covariate in the regression. If the propensity score is well-specified, will give good coverage asymptotically despite mispecifying the outcome model. Otherwise gives delta method inference for the "closest" linear model fit using clever covariate in your regression. Set to TRUE for RCT's. |
parallelize |
FALSE by default (still in development) |
a list with elements, CI for the confidence interval and IC for the influence curve.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ###
# The following example is for pt treatment.
###
# using built-in package functions, g0_linear and define Q0_linear to specify
# pscore and outcome model probabilities
data(longdata)
head(data_pt)
g0_linear
Q0_linear = function(A,W1,W2,W3,W4) plogis(A + W1 + W2 + A*(W3 + W4) + W3 +W4)
# get the truth setting A to 1
setA = 1
truth = mean(with(gendata(1e6, g0_linear, Q0_linear), Q0_linear(A=setA,W1,W2,W3,W4)))
truth
# well-specified model
n=1000
formulas = list(formula("Y ~ A + W1 + W2 + A*(W3 + W4) + W3 +W4"))
Ynodes = c("Y")
Anodes = c("A")
setA = 1
formulas_g = list(formula("A ~ W1 + W2 + W3 + W4"))
TSMinfo = long.TSM(data = data_pt, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = TRUE, setA = setA, alpha = .05)
TSMinfo1 = long.TSM(data = data_pt, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = FALSE, setA = setA, alpha = .05)
# get CI
TSMinfo$CI
TSMinfo1$CI
# get influence curve
TSMinfo$IC
# TMLE recovers truth from misspecified outcome model by getting pscore right
# non-tmle does not
# misspecified outcome regression
formulas = list(formula("Y ~ A"))
Ynodes = c("Y")
Anodes = c("A")
setA = 1
# correctly specified g
formulas_g = list(formula("A ~ W1 + W2 + W3 + W4"))
TSMinfo = long.TSM(data = data_pt, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = TRUE, setA = setA, alpha = .05)
# non-tmle
TSMinfo1 = long.TSM(data = data_pt, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = FALSE, setA = setA, alpha = .05)
# get CI
TSMinfo$CI
TSMinfo1$CI
####
# example with longitudinal intervention
####
# enter data with time-ordering correct
head(data_long)
Ynodes = c("Y_1", "Y_2","Y_3","Y_4")
Anodes = c("A1_0", "A1_1","A1_2","A1_3")
# specify the formulas
formula0 = formula("Y_1 ~ L2_0 + L1_0 + A1_0")
formula1 = formula("Y_2 ~ L2_1 + A1_1")
formula2 = formula("Y_3 ~ L2_2 + A1_2")
formulas = list(formula0, formula1, formula2)
formula_g0 = formula("A1_0 ~ L2_0 + L1_0")
formula_g1 = formula("A1_1 ~ L2_1 + A1_0")
formula_g2 = formula("A1_2 ~ L2_2 + A1_1")
formulas_g = list(formula_g0, formula_g1, formula_g2)
setA = c(0,1,1)
# tmle (takes about 6 seconds on a mac with 4 cores)
time = proc.time()
TSMinfo = long.TSM(data = data_long, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = TRUE, setA = setA, alpha = .05,
parallel = TRUE)
proc.time() - time
# non-tmle
TSMinfo1 = long.TSM(data = data_long, Ynodes = Ynodes, Anodes = Anodes,
formulas = formulas, formulas_g = formulas_g, tmle = FALSE, setA = setA, alpha = .05)
# get CI
TSMinfo$CI
# ignoring propensity score gives much smaller variance but gives small variance
# and high bias if confounding is present
TSMinfo1$CI
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.