R/AIPW_tmle.R
AIPW_tmle.Rd
AIPW_tmle
class uses a fitted tmle
or tmle3
object as input
AIPW_tmle
object
Create an AIPW_tmle object that uses the estimated efficient influence function from a fitted tmle
or tmle3
object
AIPW$new(Y = NULL, A = NULL, tmle_fit = NULL, verbose = TRUE)
Methods | Details | Link |
summary() | Summary of the average treatment effects from AIPW | summary.AIPW_base |
plot.p_score() | Plot the propensity scores by exposure status | plot.p_score |
plot.ip_weights() | Plot the inverse probability weights using truncated propensity scores | plot.ip_weights |
Variable | Generated by | Return |
n | Constructor | Number of observations |
obs_est | Constructor | Components calculating average causal effects |
estimates | summary() | A list of Risk difference, risk ratio, odds ratio |
result | summary() | A matrix contains RD, ATT, ATC, RR and OR with their SE and 95%CI |
g.plot | plot.p_score() | A density plot of propensity scores by exposure status |
ip_weights.plot | plot.ip_weights() | A box plot of inverse probability weights |
obs_est
This list extracts from the fitted tmle
or tmle3
object.
It includes propensity scores (p_score
), counterfactual predictions (mu
, mu1
& mu0
) and efficient influence functions (aipw_eif1
& aipw_eif0
)
g.plot
This plot is generated by ggplot2::geom_density
ip_weights.plot
This plot uses truncated propensity scores stratified by exposure status (ggplot2::geom_boxplot
)
if (FALSE) {
vec <- function() sample(0:1,100,replace = TRUE)
df <- data.frame(replicate(4,vec()))
names(df) <- c("A","Y","W1","W2")
## From tmle
library(tmle)
library(SuperLearner)
tmle_fit <- tmle(Y=df$Y,A=df$A,W=subset(df,select=c("W1","W2")),
Q.SL.library="SL.glm",
g.SL.library="SL.glm",
family="binomial")
AIPW_tmle$new(A=df$A,Y=df$Y,tmle_fit = tmle_fit,verbose = TRUE)$summary()
## From tmle3
# tmle3 simple implementation
library(tmle3)
library(sl3)
node_list <- list(A = "A",Y = "Y",W = c("W1","W2"))
or_spec <- tmle_OR(baseline_level = "0",contrast_level = "1")
tmle_task <- or_spec$make_tmle_task(df,node_list)
lrnr_glm <- make_learner(Lrnr_glm)
sl <- Lrnr_sl$new(learners = list(lrnr_glm))
learner_list <- list(A = sl, Y = sl)
tmle3_fit <- tmle3(or_spec, data=df, node_list, learner_list)
# parse tmle3_fit into AIPW_tmle class
AIPW_tmle$new(A=df$A,Y=df$Y,tmle_fit = tmle3_fit,verbose = TRUE)$summary()
}