Description Usage Arguments Value Author(s) References Examples
Use the cross estimation procedure with glmnet regularization to adjust covariates and estimate average treatment effects and confidence intervals
1 2 | ate.glmnet(X, Y, W, alpha = 1, nfolds = NULL, method = c("joint", "separate"),
lambda.choice = c("lambda.1se", "lambda.min"), conf.level=0.9)
|
X |
Data matrix with covariates, one observation per row |
Y |
Outcome vector for assigned treatment for each observation |
W |
Treatment vector for each observation |
alpha |
Elastic net parameter. Default 1 |
nfolds |
Number of folds |
method |
There are two methods, |
lambda.choice |
There are two cross validation choices, |
conf.level |
Confidence level for intervals. Default 0.9 |
Returns list containing the following
tau |
Average treatment effect estimate |
var |
Variance estimate |
conf.int |
Confidence interval for true tau |
conf.level |
Confidence level |
Stefan Wager, Wenfei Du, Jonathan Taylor, Rob Tibshirani
S Wager, W Du, J Taylor, and R Tibshirani. "High-dimensional regression adjustments in randomized experiments". PNAS, November 8, 2016 vol. 113 no. 45 12673-12678
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 | # simulation with Gaussian covariates based on Figure 1 in reference paper
set.seed(30)
n <- 50
p <- 100
xmean <- 1
xsigma <- 1
sigma <- .1
# set average treatment effect equal to one
ymean0 <- 4
ymean1 <- 3
# set no heterogeneous treatment effects
theta0 <- c(1, rep(0, p-1))
theta1 <- c(1, rep(0, p-1))
tau <- ymean1 - ymean0 + sum(xmean * theta1) - sum(xmean * theta0)
# run loop to calculate coverage
cover <- 0
for (i in 1:5) {
x <- matrix(rnorm(n * p, xmean, xsigma), n, p)
T <- (runif(n) < 0.2)
mu <- (ymean1 + x %*% theta1) * T + (ymean0 + x %*% theta0) * (1 - T)
epsC <- rnorm(n, 0, sigma)
epsT <- rnorm(n, 0, sigma)
eps <- epsT * T + epsC * (1 - T)
yobs <- mu + eps
res <- ate.glmnet(x, yobs, T, alpha = 1, nfolds = 10, method = "joint",
lambda.choice = "lambda.min")
cover <- cover + (res$conf.int[1] < tau & tau < res$conf.int[2])
}
cover
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.