Section 14 Box 12: tmle package

ObsData <- readRDS('rhcAnalytic.RDS')
set.seed(123)

# run tmle from the tmle package
W <- dplyr::select(ObsData, !c(Y, Y.bounded, A))
TMLE_PKG <- tmle::tmle(Y = ObsData$Y.bounded, A = ObsData$A, W = W, family = "gaussian")
TMLE_PKG
##  Additive Effect
##    Parameter Estimate:  0.0069648
##    Estimated Variance:  4.404e-06
##               p-value:  0.00090398
##     95% Conf Interval: (0.0028516, 0.011078) 
## 
##  Additive Effect among the Treated
##    Parameter Estimate:  0.0058244
##    Estimated Variance:  5.7676e-06
##               p-value:  0.015299
##     95% Conf Interval: (0.0011173, 0.010531) 
## 
##  Additive Effect among the Controls
##    Parameter Estimate:  0.0082603
##    Estimated Variance:  5.8249e-06
##               p-value:  0.00062031
##     95% Conf Interval: (0.0035299, 0.012991)
TMLE_PKG_ATE_tr <- TMLE_PKG$estimates$ATE$psi
TMLE_PKG_ATE_tr
## [1] 0.006964776
# transform back the ATE estimate using bounds of original Y
TMLE_PKG_ATE <- (max.Y-min.Y)*TMLE_PKG_ATE_tr
TMLE_PKG_ATE
## [1] 2.730192
TMLE_PKG_CI <- (max.Y-min.Y)*TMLE_PKG$estimates$ATE$CI
TMLE_PKG_CI
## [1] 1.117820 4.342564